summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2017-09-14 12:51:33 -0500
committerAndy Doan <andy.doan@linaro.org>2017-09-14 12:53:10 -0500
commitd8bd0c60487e722f8cc258826fc592df5169c99b (patch)
tree261e7cfcccb2e8d6649008f26f1f2143afac4fe5
parent9d36259b4f60aab55371536e0ae7bd37ab793877 (diff)
downloadpatchwork-tools-d8bd0c60487e722f8cc258826fc592df5169c99b.tar.gz
linaro-metrics: Add a new signed-off / non-author report
As requested this helps get an idea of upstream reviews being done by people at linaro. NOTE: these queries generate quite a bit of data. ie - 30seconds for the HTTP request to complete is normal. Using start|end parameters helps. Example uses are: * reviews for August: curl 'https://patches.linaro.org/reports/non-author-sign-offs?start=2017-08&end=2017-09' * reviews since August: curl 'https://patches.linaro.org/reports/non-author-sign-offs?start=2017-08' Change-Id: Ibd39b822d931567049c8eec4a1e39b4df4882d27
-rw-r--r--linaro_metrics/urls.py2
-rw-r--r--linaro_metrics/views.py38
2 files changed, 40 insertions, 0 deletions
diff --git a/linaro_metrics/urls.py b/linaro_metrics/urls.py
index bea47b3..0b3fe4d 100644
--- a/linaro_metrics/urls.py
+++ b/linaro_metrics/urls.py
@@ -25,6 +25,8 @@ urlpatterns = patterns(
(r'^patches/(?P<user>[^/]+)/$', 'linaro_metrics.views.user_view'),
(r'^reports/project_activity$',
'linaro_metrics.views.report_project_activity'),
+ (r'^reports/non-author-sign-offs$',
+ 'linaro_metrics.views.report_signed_off_non_author'),
url(r'^api/1.0/teams/$', TeamList.as_view(), name='api-team-list'),
url(r'^api/1.0/teams/(?P<pk>[^/]+)/$', TeamDetail.as_view(),
diff --git a/linaro_metrics/views.py b/linaro_metrics/views.py
index 78f5949..308894f 100644
--- a/linaro_metrics/views.py
+++ b/linaro_metrics/views.py
@@ -8,6 +8,7 @@ import django.template.base
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
+from django.http import StreamingHttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.html import format_html
@@ -18,6 +19,7 @@ from patchwork.templatetags.person import personify
from patchwork.templatetags.project import project_tags
from linaro_metrics.models import (
+ ProjectTagCredit,
Team,
TeamCredit,
TeamMembership,
@@ -232,6 +234,42 @@ def report_project_activity(request):
request, 'linaro_metrics/report_project_activity.html', context)
+def _signed_off_iterator(request):
+ yield '# This can take query arguments: start=YYYY-MM and end=YYYY-MM\n'
+ qs = ProjectTagCredit.objects
+ start = request.GET.get('start')
+ if start:
+ yield '# Querying with date > %s\n' % start
+ yyyy, mm = start.split('-')
+ start = datetime.datetime(int(yyyy), int(mm), 1)
+ qs = qs.filter(commit_tag__date__gt=start)
+
+ end = request.GET.get('end')
+ if end:
+ yield '# Querying with date < %s\n' % end
+ yyyy, mm = end.split('-')
+ end = datetime.datetime(int(yyyy), int(mm), 1)
+ qs = qs.filter(commit_tag__date__lt=end)
+ qs = qs.filter(
+ commit_tag__non_author=True,
+ commit_tag__tag='Signed-off'
+ ).distinct(
+ 'commit_tag__tag',
+ 'commit_tag__commit',
+ 'commit_tag__person'
+ )
+ for c in qs:
+ yield '%s,\t%s,\t%s,\t%s\n' % (
+ c.project.name, c.commit_tag.tag, c.commit_tag.commit,
+ c.commit_tag.person.name)
+
+
+def report_signed_off_non_author(request):
+ response = StreamingHttpResponse(
+ _signed_off_iterator(request), content_type="text/csv")
+ return response
+
+
def old_patch_link(request, patch):
patch = int(patch)
if patch > 55493: