Bring back topic listing
authorMagnus Hagander <magnus@hagander.net>
Tue, 29 May 2018 19:35:18 +0000 (15:35 -0400)
committerMagnus Hagander <magnus@hagander.net>
Tue, 29 May 2018 19:35:18 +0000 (15:35 -0400)
Accidentally broken when query was rewritten

pgcommitfest/commitfest/views.py

index 4f3183e6c894e031f935e5c6eadd3cc14516889b..3ee60e3c8969d9169b0428e308ae0d5511a8d252 100644 (file)
@@ -155,7 +155,6 @@ def commitfest(request, cfid):
        has_filter = len(whereclauses) > 0
 
        # Figure out custom ordering
-       ordering = ['-is_open', 'topic__topic', 'created',]
        if request.GET.has_key('sortkey') and request.GET['sortkey']!='':
                try:
                        sortkey=int(request.GET['sortkey'])
@@ -172,7 +171,7 @@ def commitfest(request, cfid):
                        orderby_str = 'p.id'
                        sortkey=0
        else:
-               orderby_str = 'p.id'
+               orderby_str = 'topic, created'
                sortkey = 0
 
        if not has_filter and sortkey==0 and request.GET:
@@ -191,16 +190,17 @@ def commitfest(request, cfid):
 
        # Let's not overload the poor django ORM
        curs = connection.cursor()
-       curs.execute("""SELECT p.id, p.name, poc.status, p.created, p.modified, p.lastmail, committer.username AS committer,
+       curs.execute("""SELECT p.id, p.name, poc.status, p.created, p.modified, p.lastmail, committer.username AS committer, t.topic,
 (poc.status=ANY(%(openstatuses)s)) AS is_open,
 (SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_authors cpa ON cpa.user_id=auth_user.id WHERE cpa.patch_id=p.id) AS author_names,
 (SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_reviewers cpr ON cpr.user_id=auth_user.id WHERE cpr.patch_id=p.id) AS reviewer_names,
 (SELECT count(1) FROM commitfest_patchoncommitfest pcf WHERE pcf.patch_id=p.id) AS num_cfs
 FROM commitfest_patch p
 INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id
+INNER JOIN commitfest_topic t ON t.id=p.topic_id
 LEFT JOIN auth_user committer ON committer.id=p.committer_id
 WHERE poc.commitfest_id=%(cid)s {0}
-GROUP BY p.id, poc.id, committer.id
+GROUP BY p.id, poc.id, committer.id, t.id
 ORDER BY is_open DESC, {1}""".format(where_str, orderby_str), params)
        patches = [dict(zip([col[0] for col in curs.description], row)) for row in curs.fetchall()]