summaryrefslogtreecommitdiff
path: root/pgcommitfest/commitfest/views.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-02-06 20:36:01 +0000
committerMagnus Hagander2019-02-06 20:36:01 +0000
commite937795ea90ba1a1b72fed942ef385b285c3a378 (patch)
treefbe56f1fd9394db4f4d352562a9ad9b4ff6fc81c /pgcommitfest/commitfest/views.py
parenta3bac5922db76efd5b6bb331a7141e9ca3209c4a (diff)
Fix activity feed queries
These clearly had little to do with reality since they would return duplicate entries if a patch was in more than one cf..
Diffstat (limited to 'pgcommitfest/commitfest/views.py')
-rw-r--r--pgcommitfest/commitfest/views.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py
index 0c9591b..c52ff9c 100644
--- a/pgcommitfest/commitfest/views.py
+++ b/pgcommitfest/commitfest/views.py
@@ -56,14 +56,12 @@ def activity(request, cfid=None, rss=None):
# we're evil. And also because the number has been verified
# when looking up the cf itself, so nothing can be injected
# there.
- extrafields = ''
- where = 'WHERE poc.commitfest_id={0}'.format(cf.id)
+ where = 'WHERE EXISTS (SELECT 1 FROM commitfest_patchoncommitfest poc2 WHERE poc2.patch_id=p.id AND poc2.commitfest_id={0})'.format(cf.id)
else:
cf = None
- extrafields = ',poc.commitfest_id AS cfid,cf.name AS cfname'
- where = ' INNER JOIN commitfest_commitfest cf ON cf.id=poc.commitfest_id'
+ where = ''
- sql = "SELECT ph.date, auth_user.username AS by, ph.what, p.id AS patchid, p.name{0} FROM commitfest_patchhistory ph INNER JOIN commitfest_patch p ON ph.patch_id=p.id INNER JOIN auth_user on auth_user.id=ph.by_id INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id {1} ORDER BY ph.date DESC LIMIT {2}".format(extrafields, where, num)
+ sql = "SELECT ph.date, auth_user.username AS by, ph.what, p.id AS patchid, p.name, (SELECT max(commitfest_id) FROM commitfest_patchoncommitfest poc WHERE poc.patch_id=p.id) AS cfid FROM commitfest_patchhistory ph INNER JOIN commitfest_patch p ON ph.patch_id=p.id INNER JOIN auth_user on auth_user.id=ph.by_id {0} ORDER BY ph.date DESC LIMIT {1}".format(where, num)
curs = connection.cursor()
curs.execute(sql)