summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2016-01-20 21:23:15 +0000
committerMagnus Hagander2016-01-20 21:23:15 +0000
commit29b26ed793696a11a04444985837df1224e7dab7 (patch)
treed683267db7739abb425c8923fb3efee69644251c
parent699ff05ae4392eb4e44a46c5202189a48ba48681 (diff)
Add report showing author/reviewer stats
Grouped by each contriubtor, show which patches this person is the author and reviewer of, to compare how many of each people have.
-rw-r--r--pgcommitfest/commitfest/reports.py45
-rw-r--r--pgcommitfest/commitfest/templates/commitfest.html7
-rw-r--r--pgcommitfest/commitfest/templates/report_authors.html37
-rw-r--r--pgcommitfest/urls.py1
4 files changed, 90 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/reports.py b/pgcommitfest/commitfest/reports.py
new file mode 100644
index 0000000..20be18f
--- /dev/null
+++ b/pgcommitfest/commitfest/reports.py
@@ -0,0 +1,45 @@
+from django.shortcuts import render_to_response, get_object_or_404
+from django.http import Http404
+from django.contrib.auth.decorators import login_required
+from django.db import connection
+
+from models import CommitFest
+
+@login_required
+def authorstats(request, cfid):
+ cf = get_object_or_404(CommitFest, pk=cfid)
+ if not request.user.is_staff:
+ raise Http404("Only CF Managers can do that.")
+
+ cursor = connection.cursor()
+ cursor.execute("""WITH patches(id,name) AS (
+ SELECT p.id, name
+ FROM commitfest_patch p
+ INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id AND poc.commitfest_id=%(cid)s
+),
+authors(userid, authorpatches) AS (
+ SELECT pa.user_id, array_agg(array_to_json(ARRAY[p.id::text, p.name]))
+ FROM commitfest_patch_authors pa
+ INNER JOIN patches p ON p.id=pa.patch_id
+ GROUP BY pa.user_id
+),
+reviewers(userid, reviewerpatches) AS (
+ SELECT pr.user_id, array_agg(array_to_json(ARRAY[p.id::text, p.name]))
+ FROM commitfest_patch_reviewers pr
+ INNER JOIN patches p ON p.id=pr.patch_id
+ GROUP BY pr.user_id
+)
+SELECT first_name || ' ' || last_name || ' (' || username ||')', authorpatches, reviewerpatches
+FROM (authors FULL OUTER JOIN reviewers ON authors.userid=reviewers.userid)
+INNER JOIN auth_user u ON u.id=COALESCE(authors.userid, reviewers.userid)
+ORDER BY last_name, first_name
+""", {
+ 'cid': cf.id,
+})
+
+ return render_to_response('report_authors.html', {
+ 'cf': cf,
+ 'report': cursor.fetchall(),
+ 'title': 'Author stats',
+ 'breadcrumbs': [{'title': cf.title, 'href': '/%s/' % cf.pk},],
+ })
diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html
index 93fb180..09b82ac 100644
--- a/pgcommitfest/commitfest/templates/commitfest.html
+++ b/pgcommitfest/commitfest/templates/commitfest.html
@@ -102,6 +102,13 @@
<li><a href="send_email/?authors={{openpatchids|join:","}}&reviewers={{openpatchids|join:","}}">All authors and reviewers (open patches)</a></li>
</ul>
</div>
+
+ <div class="btn-group dropup">
+ <button type="button" class="btn btn-default dropdown-toggle " data-toggle="dropdown" href="#">Reports <span class="caret"></span></button>
+ <ul class="dropdown-menu">
+ <li><a href="reports/authorstats/">Author stats</a></li>
+ </ul>
+ </div>
{%endif%}
</div>
{%endblock%}
diff --git a/pgcommitfest/commitfest/templates/report_authors.html b/pgcommitfest/commitfest/templates/report_authors.html
new file mode 100644
index 0000000..624e822
--- /dev/null
+++ b/pgcommitfest/commitfest/templates/report_authors.html
@@ -0,0 +1,37 @@
+{%extends "base.html"%}
+{%load commitfest %}
+{%block contents%}
+
+<table class="table table-striped table-bordered table-hover table-condensed">
+ <thead>
+ <tr>
+ <th>User</th>
+ <th>Author of</th>
+ <th>Reviewer of</th>
+ </tr>
+ </thead>
+ <tbody>
+ {%for user, authorlist, reviewlist in report %}
+ <tr>
+ <td>{{user}}</td>
+ <td>
+ <ul>
+ {%for a in authorlist%}
+ <li><a href="../../{{a.0}}/">{{a.1}}</a></li>
+ {%endfor%}
+ </ul>
+ </td>
+ <td>
+ <ul>
+ {%for r in reviewlist%}
+ <li><a href="../../{{r.0}}/">{{r.1}}</a></li>
+ {%endfor%}
+ </ul>
+ </td>
+ </tr>
+ {%endfor%}
+ </tbody>
+</table>
+
+{%endblock%}
+
diff --git a/pgcommitfest/urls.py b/pgcommitfest/urls.py
index 11153a1..952d8fe 100644
--- a/pgcommitfest/urls.py
+++ b/pgcommitfest/urls.py
@@ -21,6 +21,7 @@ urlpatterns = patterns('',
url(r'^(\d+)/(\d+)/(comment|review)/', 'pgcommitfest.commitfest.views.comment'),
url(r'^(\d+)/send_email/$', 'pgcommitfest.commitfest.views.send_email'),
url(r'^(\d+)/\d+/send_email/$', 'pgcommitfest.commitfest.views.send_email'),
+ url(r'^(\d+)/reports/authorstats/$', 'pgcommitfest.commitfest.reports.authorstats'),
url(r'^search/$', 'pgcommitfest.commitfest.views.global_search'),
url(r'^ajax/(\w+)/$', 'pgcommitfest.commitfest.ajax.main'),