Skip to content

Commit abfff8c

Browse files
committed
replaced left join with exists clause in where
1 parent cdec174 commit abfff8c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pgcommitfest/commitfest/views.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,26 @@ def me(request):
9292
"""SELECT
9393
ps.status, ps.statusstring, count(*)
9494
FROM commitfest_patchoncommitfest poc
95+
INNER JOIN commitfest_patch p ON p.id = poc.patch_id
9596
INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status
96-
LEFT JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id
97-
LEFT JOIN commitfest_patch_reviewers pr ON pr.patch_id=poc.patch_id
98-
WHERE commitfest_id=%(id)s
99-
AND
97+
WHERE
10098
ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s )
10199
AND (
102-
pa.user_id=%(user_id)s
103-
OR pr.user_id=%(user_id)s
100+
EXISTS (
101+
SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s
102+
)
103+
OR EXISTS (
104+
SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(user_id)s
105+
)
104106
)
105107
GROUP BY ps.status ORDER BY ps.sortkey""",
106-
{"id": cf.id, "user_id": request.user.id, "patch_stat_committed": PatchOnCommitFest.STATUS_COMMITTED, "patch_stat_rejected": PatchOnCommitFest.STATUS_REJECTED, "patch_stat_withdrawn": PatchOnCommitFest.STATUS_WITHDRAWN}
108+
{
109+
"user_id": request.user.id,
110+
"patch_stat_committed": PatchOnCommitFest.STATUS_COMMITTED,
111+
"patch_stat_rejected": PatchOnCommitFest.STATUS_REJECTED,
112+
"patch_stat_withdrawn": PatchOnCommitFest.STATUS_WITHDRAWN,
113+
"patch_stat_nextcf": PatchOnCommitFest.STATUS_NEXT,
114+
},
107115
)
108116
statussummary = curs.fetchall()
109117

0 commit comments

Comments
 (0)