Skip to content

Commit

Permalink
Merge pull request #722 from mstriemer/other-reviewer-scores-841742
Browse files Browse the repository at this point in the history
Include other reviewer scores on the performance page (bug 841742)
  • Loading branch information
mstriemer committed Sep 9, 2015
2 parents 8c5ea11 + 3221c3b commit 1444c97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/editors/templates/editors/performance.html
@@ -1,6 +1,6 @@
{% extends "editors/base.html" %}

{% set types = ('addons', 'themes') %}
{% set types = ('addons', 'themes', 'other') %}

{% block breadcrumbs %}
{{ editors_breadcrumbs(items=[(None, _('Performance'))]) }}
Expand Down Expand Up @@ -71,6 +71,8 @@ <h2>{{ _('All-time Point Breakdown by Type') }}</h2>
<th></th>
<th>{{ _('Add-ons') }}</th>
<th>{{ _('Themes') }}</th>
{# L10n: Review points sources other than add-ons and themes. #}
<th>{{ _('Other') }}</th>
<th>{{ _('Total') }}</th>
</tr>
</thead>
Expand Down
15 changes: 13 additions & 2 deletions apps/editors/views.py
Expand Up @@ -222,21 +222,32 @@ def performance(request, user_id=False):
months = ReviewerScore.get_breakdown_since(user, month_ago)
years = ReviewerScore.get_breakdown_since(user, year_ago)

def _sum(iter, types):
return sum(s.total for s in iter if s.atype in types)
def _sum(iter, types, exclude=False):
"""Sum the `total` property for items in `iter` that have an `atype`
that is included in `types` when `exclude` is False (default) or not in
`types` when `exclude` is True."""
return sum(s.total
for s in iter
if (s.atype in types) == (not exclude))

breakdown = {
'month': {
'addons': _sum(months, amo.GROUP_TYPE_ADDON),
'themes': _sum(months, amo.GROUP_TYPE_THEME),
'other': _sum(months, amo.GROUP_TYPE_ADDON + amo.GROUP_TYPE_THEME,
exclude=True)
},
'year': {
'addons': _sum(years, amo.GROUP_TYPE_ADDON),
'themes': _sum(years, amo.GROUP_TYPE_THEME),
'other': _sum(years, amo.GROUP_TYPE_ADDON + amo.GROUP_TYPE_THEME,
exclude=True)
},
'total': {
'addons': _sum(totals, amo.GROUP_TYPE_ADDON),
'themes': _sum(totals, amo.GROUP_TYPE_THEME),
'other': _sum(totals, amo.GROUP_TYPE_ADDON + amo.GROUP_TYPE_THEME,
exclude=True)
}
}

Expand Down

0 comments on commit 1444c97

Please sign in to comment.