Skip to content

Commit 9d785d9

Browse files
committed
Simplify query
1 parent a9a3b98 commit 9d785d9

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

pgcommitfest/commitfest/views.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -620,22 +620,12 @@ def commitfest(request, cfid):
620620
return patch_list.redirect
621621

622622
# Generate patch status summary.
623-
if cf.draft:
624-
# Exclude "Moved to other CF" status from draft commitfests
625-
curs.execute(
626-
"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 AND poc.status != %(status_moved)s GROUP BY ps.status ORDER BY ps.sortkey",
627-
{
628-
"id": cf.id,
629-
"status_moved": PatchOnCommitFest.STATUS_MOVED,
630-
},
631-
)
632-
else:
633-
curs.execute(
634-
"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",
635-
{
636-
"id": cf.id,
637-
},
638-
)
623+
# Exclude "Moved to other CF" status from draft commitfests
624+
status_filter = "AND poc.status != %(status_moved)s" if cf.draft else ""
625+
curs.execute(
626+
f"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 {status_filter} GROUP BY ps.status ORDER BY ps.sortkey",
627+
{"id": cf.id, "status_moved": PatchOnCommitFest.STATUS_MOVED},
628+
)
639629
statussummary = curs.fetchall()
640630
statussummary.append([-1, "Total", sum((r[2] for r in statussummary))])
641631

0 commit comments

Comments
 (0)