summaryrefslogtreecommitdiff
path: root/pgcommitfest/commitfest
diff options
context:
space:
mode:
authorMagnus Hagander2015-02-07 12:31:59 +0000
committerMagnus Hagander2015-02-07 12:31:59 +0000
commit2bf6b909fd42f09ada9667264b9a0300f15503d9 (patch)
tree57c43a29d428f04b685081fdfe8e25063a0d1c16 /pgcommitfest/commitfest
parentd251d24f6e0d94871334deb070643f2b47caa918 (diff)
Add status summary to top of each commitfest list
Quick overview of how many patches are in each status, as exist on the old app.
Diffstat (limited to 'pgcommitfest/commitfest')
-rw-r--r--pgcommitfest/commitfest/fixtures/initial_data.json50
-rw-r--r--pgcommitfest/commitfest/models.py9
-rw-r--r--pgcommitfest/commitfest/templates/commitfest.html5
-rw-r--r--pgcommitfest/commitfest/views.py9
4 files changed, 73 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/fixtures/initial_data.json b/pgcommitfest/commitfest/fixtures/initial_data.json
new file mode 100644
index 0000000..e33e662
--- /dev/null
+++ b/pgcommitfest/commitfest/fixtures/initial_data.json
@@ -0,0 +1,50 @@
+[
+ {
+ "pk": 1,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Needs review",
+ "sortkey": 10
+ }
+ },
+ {
+ "pk": 2,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Waiting on Author",
+ "sortkey": 15
+ }
+ },
+ {
+ "pk": 3,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Ready for Committer",
+ "sortkey": 20
+ }
+ },
+ {
+ "pk": 4,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Committed",
+ "sortkey": 25
+ }
+ },
+ {
+ "pk": 5,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Returned with Feedback",
+ "sortkey": 30
+ }
+ },
+ {
+ "pk": 6,
+ "model": "commitfest.patchstatus",
+ "fields": {
+ "statusstring": "Rejected",
+ "sortkey": 50
+ }
+ }
+] \ No newline at end of file
diff --git a/pgcommitfest/commitfest/models.py b/pgcommitfest/commitfest/models.py
index d60a1aa..f118bc2 100644
--- a/pgcommitfest/commitfest/models.py
+++ b/pgcommitfest/commitfest/models.py
@@ -137,6 +137,10 @@ class Patch(models.Model, DiffableModel):
verbose_name_plural = 'patches'
class PatchOnCommitFest(models.Model):
+ # NOTE! This is also matched by the commitfest_patchstatus table,
+ # but we hardcoded it in here simply for performance reasons since
+ # the data should be entirely static. (Yes, that's something we
+ # might re-evaluate in the future)
STATUS_REVIEW=1
STATUS_AUTHOR=2
STATUS_COMMITTER=3
@@ -222,3 +226,8 @@ class MailThreadAttachment(models.Model):
class Meta:
ordering = ('-date',)
unique_together = (('mailthread', 'messageid',), )
+
+class PatchStatus(models.Model):
+ status = models.IntegerField(null=False, blank=False, primary_key=True)
+ statusstring = models.TextField(max_length=50, null=False, blank=False)
+ sortkey = models.IntegerField(null=False, blank=False, default=10)
diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html
index 2097ed8..056808f 100644
--- a/pgcommitfest/commitfest/templates/commitfest.html
+++ b/pgcommitfest/commitfest/templates/commitfest.html
@@ -37,6 +37,11 @@
</form>
</div>
+<p>
+<br/>
+<b>Status summary: </b>{%for id,title,num in statussummary%}<a href="?status={{id}}">{{title}}</a>: {{num}}. {%endfor%}
+</p>
+
{%for p in patches %}
{%ifchanged p.is_open%}
{%if not forloop.first%}
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py
index ab622c9..55302d9 100644
--- a/pgcommitfest/commitfest/views.py
+++ b/pgcommitfest/commitfest/views.py
@@ -147,6 +147,14 @@ def commitfest(request, cfid):
'is_open':'commitfest_patchoncommitfest.status IN (%s)' % ','.join([str(x) for x in PatchOnCommitFest.OPEN_STATUSES]),
}).order_by(*ordering))
+ # Generate patch status summary.
+ curs = connection.cursor()
+ curs.execute("SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE commitfest_id=%(id)s GROUP BY ps.status ORDER BY ps.sortkey", {
+ 'id': cf.id,
+ })
+ statussummary = curs.fetchall()
+ statussummary.append([-1, 'Total', sum((r[2] for r in statussummary))])
+
# Generates a fairly expensive query, which we shouldn't do unless
# the user is logged in. XXX: Figure out how to avoid doing that..
form = CommitFestFilterForm(cf, request.GET)
@@ -155,6 +163,7 @@ def commitfest(request, cfid):
'cf': cf,
'form': form,
'patches': patches,
+ 'statussummary': statussummary,
'has_filter': has_filter,
'title': cf.title,
'grouping': sortkey==0,