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