summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linaro_metrics/templates/linaro_metrics/report_project_activity.html8
-rw-r--r--linaro_metrics/views.py26
2 files changed, 33 insertions, 1 deletions
diff --git a/linaro_metrics/templates/linaro_metrics/report_project_activity.html b/linaro_metrics/templates/linaro_metrics/report_project_activity.html
index dc843c2..2232493 100644
--- a/linaro_metrics/templates/linaro_metrics/report_project_activity.html
+++ b/linaro_metrics/templates/linaro_metrics/report_project_activity.html
@@ -13,4 +13,12 @@
{% endfor %}
<table>
+<h2>Top Accepted {{ summary|length}} Linaro Project Contributions</h2>
+<table class="table">
+ <tr><th>Project</th><th>12 months</th><th>6 months</th><th>3 months</th><th>1 month</th></tr>
+{% for s in accepted %}
+ <tr class="{% cycle 'odd' 'even' %}">{% for td in s %}<td>{{td}}</td>{% endfor %}</tr>
+{% endfor %}
+<table>
+
{% endblock %}
diff --git a/linaro_metrics/views.py b/linaro_metrics/views.py
index ee88dbe..1b86d17 100644
--- a/linaro_metrics/views.py
+++ b/linaro_metrics/views.py
@@ -23,6 +23,7 @@ from linaro_metrics.models import (
Team,
TeamCredit,
TeamMembership,
+ State,
)
@@ -211,6 +212,8 @@ def report_project_activity(request):
last_1 = _subtract_months(last_full_month, 1)
summary = {}
+ accepted = {}
+
qs = TeamCredit.patch_count_by_month(
12, values=('month', 'patch__project__name'),
patch__date__lte=last_full_month)
@@ -229,7 +232,28 @@ def report_project_activity(request):
items = [(x, y['last_12'], y['last_6'], y['last_3'], y['last_1'])
for x, y in summary.iteritems()]
summary = sorted(items, key=lambda x: x[1], reverse=True)[:20]
- context = {'summary': summary}
+
+ qs_a = TeamCredit.patch_count_by_month(
+ 12, values=('month', 'patch__project__name'),
+ patch__date__lte=last_full_month,
+ state=State.objects.get(name='Accepted'))
+ for x in qs_a:
+ e = accepted.setdefault(
+ x['patch__project__name'], {
+ 'last_12': 0, 'last_6': 0, 'last_3': 0, 'last_1': 0})
+ if x['month'] >= last_1:
+ e['last_1'] += x['patch__pk__count']
+ if x['month'] >= last_3:
+ e['last_3'] += x['patch__pk__count']
+ if x['month'] >= last_6:
+ e['last_6'] += x['patch__pk__count']
+ if x['month'] >= last_12:
+ e['last_12'] += x['patch__pk__count']
+ items = [(x, y['last_12'], y['last_6'], y['last_3'], y['last_1'])
+ for x, y in accepted.iteritems()]
+ accepted = sorted(items, key=lambda x: x[1], reverse=True)[:20]
+
+ context = {'summary': summary, 'accepted': accepted}
return render(
request, 'linaro_metrics/report_project_activity.html', context)