From c7eae5c780768c00987789255a0580318584158b Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 29 May 2018 15:35:18 -0400 Subject: [PATCH] Bring back topic listing Accidentally broken when query was rewritten --- pgcommitfest/commitfest/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 4f3183e..3ee60e3 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -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()] -- 2.39.5