@@ -155,7 +155,6 @@ def commitfest(request, cfid):
155155 has_filter = len (whereclauses ) > 0
156156
157157 # Figure out custom ordering
158- ordering = ['-is_open' , 'topic__topic' , 'created' ,]
159158 if request .GET .has_key ('sortkey' ) and request .GET ['sortkey' ]!= '' :
160159 try :
161160 sortkey = int (request .GET ['sortkey' ])
@@ -172,7 +171,7 @@ def commitfest(request, cfid):
172171 orderby_str = 'p.id'
173172 sortkey = 0
174173 else :
175- orderby_str = 'p.id '
174+ orderby_str = 'topic, created '
176175 sortkey = 0
177176
178177 if not has_filter and sortkey == 0 and request .GET :
@@ -191,16 +190,17 @@ def commitfest(request, cfid):
191190
192191 # Let's not overload the poor django ORM
193192 curs = connection .cursor ()
194- curs .execute ("""SELECT p.id, p.name, poc.status, p.created, p.modified, p.lastmail, committer.username AS committer,
193+ curs .execute ("""SELECT p.id, p.name, poc.status, p.created, p.modified, p.lastmail, committer.username AS committer, t.topic,
195194(poc.status=ANY(%(openstatuses)s)) AS is_open,
196195(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,
197196(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,
198197(SELECT count(1) FROM commitfest_patchoncommitfest pcf WHERE pcf.patch_id=p.id) AS num_cfs
199198FROM commitfest_patch p
200199INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id
200+ INNER JOIN commitfest_topic t ON t.id=p.topic_id
201201LEFT JOIN auth_user committer ON committer.id=p.committer_id
202202WHERE poc.commitfest_id=%(cid)s {0}
203- GROUP BY p.id, poc.id, committer.id
203+ GROUP BY p.id, poc.id, committer.id, t.id
204204ORDER BY is_open DESC, {1}""" .format (where_str , orderby_str ), params )
205205 patches = [dict (zip ([col [0 ] for col in curs .description ], row )) for row in curs .fetchall ()]
206206
0 commit comments