sort by adus (bug 589364)
This commit is contained in:
Родитель
2013984bd6
Коммит
5c74c9b02f
|
@ -111,6 +111,7 @@ def update_addon_average_daily_users():
|
|||
addon_id, AVG(`count`)
|
||||
FROM update_counts
|
||||
USE KEY (`addon_and_count`)
|
||||
WHERE `date` >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
|
||||
GROUP BY addon_id
|
||||
ORDER BY addon_id"""
|
||||
cursor.execute(q)
|
||||
|
|
|
@ -6,6 +6,7 @@ CREATE INDEX created_type_idx ON addons (created, addontype_id);
|
|||
CREATE INDEX rating_type_idx ON addons (bayesianrating, addontype_id);
|
||||
CREATE INDEX last_updated_type_idx ON addons (last_updated, addontype_id);
|
||||
CREATE INDEX type_status_inactive_idx ON addons (addontype_id, status, inactive);
|
||||
CREATE INDEX adus_type_idx ON addons (average_daily_users, addontype_id);
|
||||
|
||||
CREATE INDEX `personas_movers_idx` ON personas (movers);
|
||||
CREATE INDEX `personas_popularity_idx` ON personas (popularity);
|
||||
|
|
|
@ -19,6 +19,15 @@
|
|||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</span>
|
||||
{% elif sort == 'users' %}
|
||||
<span class="vital">
|
||||
{% with num=addon.average_daily_users %}
|
||||
{# L10n: {0} is the number of users. #}
|
||||
{{ ngettext("<strong>{0}</strong> user",
|
||||
"<strong>{0}</strong> users",
|
||||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</span>
|
||||
{% else %}
|
||||
{% with num=addon.total_reviews %}
|
||||
{% if num %}
|
||||
|
|
|
@ -19,21 +19,19 @@
|
|||
|
||||
{% macro item_info(addon, amo, show_date) %}
|
||||
{{ reviews_link(addon) }}
|
||||
{% if addon.status != amo.STATUS_LISTED %}
|
||||
<p class="downloads">
|
||||
{% with num=addon.weekly_downloads %}
|
||||
{# L10n: {0} is the number of downloads. #}
|
||||
{{ ngettext("<strong>{0}</strong> weekly download",
|
||||
"<strong>{0}</strong> weekly downloads",
|
||||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</p>
|
||||
<p class="updated">
|
||||
{% if show_date in ['created', 'new', 'newest'] %}
|
||||
{{ _('Added {0}')|f(addon.created|datetime) }}
|
||||
{% elif show_date == 'updated' %}
|
||||
{{ _('Updated {0}')|f(addon.last_updated|datetime) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p class="downloads">
|
||||
{% with num=addon.average_daily_users %}
|
||||
{# L10n: {0} is the number of users. #}
|
||||
{{ ngettext("<strong>{0}</strong> user",
|
||||
"<strong>{0}</strong> users",
|
||||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</p>
|
||||
<p class="updated">
|
||||
{% if show_date in ['created', 'new', 'newest'] %}
|
||||
{{ _('Added {0}')|f(addon.created|datetime) }}
|
||||
{% elif show_date == 'updated' %}
|
||||
{{ _('Updated {0}')|f(addon.last_updated|datetime) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
|
|
@ -334,6 +334,10 @@ class BaseFilter(object):
|
|||
return (Addon.objects.order_by('-weekly_downloads')
|
||||
.with_index(addons='downloads_type_idx'))
|
||||
|
||||
def filter_users(self):
|
||||
return (Addon.objects.order_by('-average_daily_users')
|
||||
.with_index(addons='adus_type_idx'))
|
||||
|
||||
def filter_created(self):
|
||||
return (Addon.objects.order_by('-created')
|
||||
.with_index(addons='created_type_idx'))
|
||||
|
@ -404,7 +408,7 @@ def impala_home(request):
|
|||
application=request.APP.id,
|
||||
type=amo.COLLECTION_FEATURED)
|
||||
featured = base.filter(id__in=featured_ids)[:18]
|
||||
popular = base.order_by('-weekly_downloads')[:10]
|
||||
popular = base.order_by('-average_daily_users')[:10]
|
||||
hotness = base.order_by('-hotness')[:18]
|
||||
personas = (Addon.objects.listed(request.APP)
|
||||
.filter(type=amo.ADDON_PERSONA, id__in=featured_ids))[:18]
|
||||
|
@ -423,14 +427,14 @@ def home(request):
|
|||
# Get some featured add-ons with randomness.
|
||||
featured = rand(Addon.featured(request.APP, request.LANG).keys())
|
||||
# Get 10 popular add-ons, then pick 3 at random.
|
||||
qs = list(Addon.objects.listed(request.APP).order_by('-weekly_downloads')
|
||||
qs = list(Addon.objects.listed(request.APP).order_by('-average_daily_users')
|
||||
.values_list('id', flat=True)[:10])
|
||||
popular = rand(qs)
|
||||
# Do one query and split up the add-ons.
|
||||
addons = Addon.objects.filter(id__in=featured + popular)
|
||||
featured = [a for a in addons if a.id in featured]
|
||||
popular = sorted([a for a in addons if a.id in popular],
|
||||
key=attrgetter('weekly_downloads'), reverse=True)
|
||||
key=attrgetter('average_daily_users'), reverse=True)
|
||||
return jingo.render(request, 'addons/mobile/home.html',
|
||||
{'featured': featured, 'popular': popular})
|
||||
|
||||
|
|
|
@ -79,6 +79,12 @@
|
|||
{{ ngettext("{0} weekly download", "{0} weekly downloads",
|
||||
num)|f(num|numberfmt) }}
|
||||
{% endwith %}
|
||||
{% elif sorting == "users" %}
|
||||
{% with num=addon.average_daily_users %}
|
||||
{# L10n: {0} is the number of users. #}
|
||||
{{ ngettext("{0} user", "{0} users",
|
||||
num)|f(num|numberfmt) }}
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
{% with num=addon.total_reviews %}
|
||||
{% if num %}
|
||||
|
|
|
@ -52,6 +52,7 @@ class AddonFilter(BaseFilter):
|
|||
('updated', _lazy(u'Updated')),
|
||||
('created', _lazy(u'Created')),
|
||||
('popular', _lazy(u'Downloads')),
|
||||
('users', _lazy(u'Users')),
|
||||
('rating', _lazy(u'Rating')))
|
||||
|
||||
|
||||
|
@ -301,6 +302,7 @@ class SearchToolsFilter(AddonFilter):
|
|||
('updated', _lazy(u'Updated')),
|
||||
('created', _lazy(u'Created')),
|
||||
('popular', _lazy(u'Downloads')),
|
||||
('users', _lazy(u'Users')),
|
||||
('rating', _lazy(u'Rating')))
|
||||
|
||||
def filter(self, field):
|
||||
|
|
|
@ -9,16 +9,14 @@
|
|||
|
||||
{% macro dev_item_info(addon, amo) %}
|
||||
{{ reviews_link(addon) }}
|
||||
{% if addon.status != amo.STATUS_LISTED %}
|
||||
<p class="downloads">
|
||||
{% with num=addon.weekly_downloads %}
|
||||
{# L10n: {0} is the number of downloads. #}
|
||||
{{ ngettext("<strong>{0}</strong> weekly download",
|
||||
"<strong>{0}</strong> weekly downloads",
|
||||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p class="downloads">
|
||||
{% with num=addon.weekly_downloads %}
|
||||
{# L10n: {0} is the number of downloads. #}
|
||||
{{ ngettext("<strong>{0}</strong> weekly download",
|
||||
"<strong>{0}</strong> weekly downloads",
|
||||
num)|f(num|numberfmt)|safe }}
|
||||
{% endwith %}
|
||||
</p>
|
||||
<p class="users">
|
||||
{% with num=addon.average_daily_users %}
|
||||
{# L10n: {0} is the number of active users. #}
|
||||
|
|
|
@ -432,6 +432,7 @@ class Client(object):
|
|||
'averagerating': 'averagerating DESC',
|
||||
'popularity': 'weeklydownloads DESC',
|
||||
'weeklydownloads': 'weeklydownloads DESC',
|
||||
'users': 'average_daily_users DESC',
|
||||
}
|
||||
|
||||
if 'sort' in kwargs and kwargs['sort']:
|
||||
|
|
|
@ -14,11 +14,11 @@ types = (amo.ADDON_ANY, amo.ADDON_EXTENSION, amo.ADDON_THEME, amo.ADDON_DICT,
|
|||
|
||||
sort_by = (
|
||||
('', _lazy(u'Keyword Match')),
|
||||
('newest', _lazy(u'Newest', 'advanced_search_form_newest')),
|
||||
('updated', _lazy(u'Updated', 'advanced_search_form_updated')),
|
||||
('newest', _lazy(u'Created', 'advanced_search_form_newest')),
|
||||
('weeklydownloads', _lazy(u'Downloads')),
|
||||
('users', _lazy(u'Users')),
|
||||
('averagerating', _lazy(u'Rating', 'advanced_search_form_rating')),
|
||||
('weeklydownloads', _lazy(u'Popularity',
|
||||
'advanced_search_form_popularity')),
|
||||
)
|
||||
|
||||
collection_sort_by = (
|
||||
|
|
|
@ -74,7 +74,7 @@ source addons
|
|||
id, app, addon_id, type, status as addon_status, locale, \
|
||||
locale_ord, averagerating, weeklydownloads, totaldownloads, \
|
||||
inactive, guid_ord, name, UPPER(name) AS name_ord, \
|
||||
description, summary, developercomments, \
|
||||
description, summary, developercomments, average_daily_users, \
|
||||
( \
|
||||
SELECT 1 FROM features f \
|
||||
WHERE f.addon_id=t.addon_id \
|
||||
|
@ -138,6 +138,7 @@ source addons
|
|||
a.bayesianrating AS averagerating, \
|
||||
a.weeklydownloads, \
|
||||
a.totaldownloads, \
|
||||
a.average_daily_users, \
|
||||
a.inactive, \
|
||||
LTRIM(name.localized_string) AS name, \
|
||||
description.localized_string AS description, \
|
||||
|
@ -182,6 +183,7 @@ source addons
|
|||
sql_attr_uint = type
|
||||
sql_attr_uint = addon_status
|
||||
sql_attr_uint = weeklydownloads
|
||||
sql_attr_uint = average_daily_users
|
||||
sql_attr_uint = totaldownloads
|
||||
sql_attr_uint = locale_ord
|
||||
sql_attr_bigint = max_ver
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
CREATE INDEX adus_type_idx ON addons (average_daily_users, addontype_id);
|
Загрузка…
Ссылка в новой задаче