From 3f1bc1da63afd2cfbe56c4591ad4c59236e1029b Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Wed, 5 Mar 2025 23:43:36 +0530 Subject: [PATCH 01/11] added stats to commitfest personal dashboard page --- pgcommitfest/commitfest/templates/me.html | 5 +++++ pgcommitfest/commitfest/views.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/templates/me.html b/pgcommitfest/commitfest/templates/me.html index 5435e6c..1969812 100644 --- a/pgcommitfest/commitfest/templates/me.html +++ b/pgcommitfest/commitfest/templates/me.html @@ -1,6 +1,11 @@ {%extends "base.html"%} {%load commitfest %} {%block contents%} +

+
+ Status summary: {%for id,title,num in statussummary%}{{title}}: {{num}}. {%endfor%} +

+ New patch Current commitfest Open commitfest diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 471f322..cea8b4c 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -86,6 +86,18 @@ def me(request): if patch_list.redirect: return patch_list.redirect + # Get stats related to user for current commitfest + curs = connection.cursor() + curs.execute( + "SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status INNER JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id WHERE commitfest_id=%(id)s AND pa.user_id=%(user_id)s GROUP BY ps.status ORDER BY ps.sortkey", + { + "id": cf.id, + "user_id": request.user.id + }, + ) + statussummary = curs.fetchall() + print(statussummary) + return render( request, "me.html", @@ -93,7 +105,7 @@ def me(request): "form": form, "title": "Personal Dashboard", "patches": patch_list.patches, - "statussummary": "", + "statussummary": statussummary, "has_filter": patch_list.has_filter, "grouping": patch_list.sortkey == 0, "sortkey": patch_list.sortkey, From c8482b52f20d12b0f7bbd6bd4fecd846ba33ef64 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Wed, 5 Mar 2025 23:58:54 +0530 Subject: [PATCH 02/11] fixed query to include patches where user is either a reviewer or has subscribed to --- pgcommitfest/commitfest/views.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index cea8b4c..4a34fda 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -89,7 +89,20 @@ def me(request): # Get stats related to user for current commitfest curs = connection.cursor() curs.execute( - "SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status INNER JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id WHERE commitfest_id=%(id)s AND pa.user_id=%(user_id)s GROUP BY ps.status ORDER BY ps.sortkey", + '''SELECT + ps.status, ps.statusstring, count(*) + FROM commitfest_patchoncommitfest poc + INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status + LEFT JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id + LEFT JOIN commitfest_patch_reviewers pr ON pr.patch_id=poc.patch_id + LEFT JOIN commitfest_patch_subscribers psubs ON psubs.patch_id=poc.patch_id + WHERE commitfest_id=%(id)s + AND ( + pa.user_id=%(user_id)s + OR pr.user_id=%(user_id)s + OR psubs.user_id=%(user_id)s + ) + GROUP BY ps.status ORDER BY ps.sortkey''', { "id": cf.id, "user_id": request.user.id From bb4e557f11326a1d3a1b8d07fb7f191d37365b11 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Thu, 6 Mar 2025 00:01:56 +0530 Subject: [PATCH 03/11] fixed linting errors in views.py --- pgcommitfest/commitfest/views.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 4a34fda..fb9aacb 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -89,7 +89,7 @@ def me(request): # Get stats related to user for current commitfest curs = connection.cursor() curs.execute( - '''SELECT + """SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status @@ -102,11 +102,8 @@ def me(request): OR pr.user_id=%(user_id)s OR psubs.user_id=%(user_id)s ) - GROUP BY ps.status ORDER BY ps.sortkey''', - { - "id": cf.id, - "user_id": request.user.id - }, + GROUP BY ps.status ORDER BY ps.sortkey""", + {"id": cf.id, "user_id": request.user.id}, ) statussummary = curs.fetchall() print(statussummary) From ff3fe8a58ab2aa9ea290f884404cd87b76f08db3 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 14 Mar 2025 01:00:06 +0530 Subject: [PATCH 04/11] removed print statements; removed subscribers in status list data --- pgcommitfest/commitfest/templates/me.html | 12 +++++++----- pgcommitfest/commitfest/views.py | 7 ++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pgcommitfest/commitfest/templates/me.html b/pgcommitfest/commitfest/templates/me.html index 1969812..fd50f63 100644 --- a/pgcommitfest/commitfest/templates/me.html +++ b/pgcommitfest/commitfest/templates/me.html @@ -1,11 +1,6 @@ {%extends "base.html"%} {%load commitfest %} {%block contents%} -

-
- Status summary: {%for id,title,num in statussummary%}{{title}}: {{num}}. {%endfor%} -

- New patch Current commitfest Open commitfest @@ -16,6 +11,13 @@ + +

+
+ Status summary: {%for id,title,num in statussummary%}{{title}}: {{num}}. {%endfor%} +

+ + {%include "filter_form.html" %} {%for p in patches %} {%ifchanged p.is_open%} diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index fb9aacb..5de044f 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -95,18 +95,15 @@ def me(request): INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status LEFT JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id LEFT JOIN commitfest_patch_reviewers pr ON pr.patch_id=poc.patch_id - LEFT JOIN commitfest_patch_subscribers psubs ON psubs.patch_id=poc.patch_id - WHERE commitfest_id=%(id)s + WHERE commitfest_id=%(id)s AND ( - pa.user_id=%(user_id)s + pa.user_id=%(user_id)s OR pr.user_id=%(user_id)s - OR psubs.user_id=%(user_id)s ) GROUP BY ps.status ORDER BY ps.sortkey""", {"id": cf.id, "user_id": request.user.id}, ) statussummary = curs.fetchall() - print(statussummary) return render( request, From cdec17447de78e09ef5fffeb1785062fd93f789d Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 14 Mar 2025 01:21:10 +0530 Subject: [PATCH 05/11] added check to exclude closed patches --- pgcommitfest/commitfest/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 5de044f..57da628 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -96,12 +96,14 @@ def me(request): LEFT JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id LEFT JOIN commitfest_patch_reviewers pr ON pr.patch_id=poc.patch_id WHERE commitfest_id=%(id)s + AND + ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s ) AND ( pa.user_id=%(user_id)s OR pr.user_id=%(user_id)s ) GROUP BY ps.status ORDER BY ps.sortkey""", - {"id": cf.id, "user_id": request.user.id}, + {"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} ) statussummary = curs.fetchall() From abfff8c7c9867bf1afc4fa96e7777b90cd5f2b99 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 14 Mar 2025 01:42:55 +0530 Subject: [PATCH 06/11] replaced left join with exists clause in where --- pgcommitfest/commitfest/views.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 57da628..7e629ff 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -92,18 +92,26 @@ def me(request): """SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc + INNER JOIN commitfest_patch p ON p.id = poc.patch_id INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status - LEFT JOIN commitfest_patch_authors pa ON pa.patch_id=poc.patch_id - LEFT JOIN commitfest_patch_reviewers pr ON pr.patch_id=poc.patch_id - WHERE commitfest_id=%(id)s - AND + WHERE ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s ) AND ( - pa.user_id=%(user_id)s - OR pr.user_id=%(user_id)s + EXISTS ( + SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s + ) + OR EXISTS ( + SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(user_id)s + ) ) GROUP BY ps.status ORDER BY ps.sortkey""", - {"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} + { + "user_id": request.user.id, + "patch_stat_committed": PatchOnCommitFest.STATUS_COMMITTED, + "patch_stat_rejected": PatchOnCommitFest.STATUS_REJECTED, + "patch_stat_withdrawn": PatchOnCommitFest.STATUS_WITHDRAWN, + "patch_stat_nextcf": PatchOnCommitFest.STATUS_NEXT, + }, ) statussummary = curs.fetchall() From f0f6ebcee51d7d9f0eeaf6b5b9c652d811f8b978 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 14 Mar 2025 01:43:57 +0530 Subject: [PATCH 07/11] minor fix for stats --- pgcommitfest/commitfest/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 7e629ff..6a8ead4 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -95,7 +95,7 @@ def me(request): INNER JOIN commitfest_patch p ON p.id = poc.patch_id INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE - ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s ) + ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s, %(patch_stat_nextcf)s ) AND ( EXISTS ( SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s From 75b5fb467ae6df0dcb4f174441ecfab7ff50f328 Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 14 Mar 2025 01:47:47 +0530 Subject: [PATCH 08/11] added returned with feedback to not in filter --- pgcommitfest/commitfest/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 6a8ead4..c18edbe 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -95,7 +95,7 @@ def me(request): INNER JOIN commitfest_patch p ON p.id = poc.patch_id INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE - ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s, %(patch_stat_nextcf)s ) + ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s, %(patch_stat_nextcf)s, %(patch_stat_retwfdb)s ) AND ( EXISTS ( SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s @@ -111,6 +111,7 @@ def me(request): "patch_stat_rejected": PatchOnCommitFest.STATUS_REJECTED, "patch_stat_withdrawn": PatchOnCommitFest.STATUS_WITHDRAWN, "patch_stat_nextcf": PatchOnCommitFest.STATUS_NEXT, + "patch_stat_retwfdb": PatchOnCommitFest.STATUS_RETURNED, }, ) statussummary = curs.fetchall() From d716195b4cca31223dd2b2ddee82d59015e70e0b Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 21 Mar 2025 12:32:12 +0530 Subject: [PATCH 09/11] make stats query consistent Co-authored-by: Jelte Fennema-Nio --- pgcommitfest/commitfest/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index c18edbe..d23346f 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -95,7 +95,7 @@ def me(request): INNER JOIN commitfest_patch p ON p.id = poc.patch_id INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE - ps.status NOT IN ( %(patch_stat_committed)s, %(patch_stat_rejected)s, %(patch_stat_withdrawn)s, %(patch_stat_nextcf)s, %(patch_stat_retwfdb)s ) + ps.statusstatus = ANY(%(openstatuses)s) AND ( EXISTS ( SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s From b4258efea31ce2a9d0a9a9c6d7acacefae619a1f Mon Sep 17 00:00:00 2001 From: Akshat Jaimini Date: Fri, 21 Mar 2025 12:32:34 +0530 Subject: [PATCH 10/11] updated query Co-authored-by: Jelte Fennema-Nio --- pgcommitfest/commitfest/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index d23346f..c5c846d 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -103,6 +103,7 @@ def me(request): OR EXISTS ( SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(user_id)s ) + OR p.committer_id=%(user_id)s ) GROUP BY ps.status ORDER BY ps.sortkey""", { From 7f765796986c3abdf231bb100261fff1181006f9 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Sat, 22 Mar 2025 14:05:32 +0100 Subject: [PATCH 11/11] Fix issues --- pgcommitfest/commitfest/views.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index c5c846d..6be17ee 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -95,7 +95,7 @@ def me(request): INNER JOIN commitfest_patch p ON p.id = poc.patch_id INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE - ps.statusstatus = ANY(%(openstatuses)s) + ps.status = ANY(%(openstatuses)s) AND ( EXISTS ( SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s @@ -108,11 +108,7 @@ def me(request): GROUP BY ps.status ORDER BY ps.sortkey""", { "user_id": request.user.id, - "patch_stat_committed": PatchOnCommitFest.STATUS_COMMITTED, - "patch_stat_rejected": PatchOnCommitFest.STATUS_REJECTED, - "patch_stat_withdrawn": PatchOnCommitFest.STATUS_WITHDRAWN, - "patch_stat_nextcf": PatchOnCommitFest.STATUS_NEXT, - "patch_stat_retwfdb": PatchOnCommitFest.STATUS_RETURNED, + "openstatuses": PatchOnCommitFest.OPEN_STATUSES, }, ) statussummary = curs.fetchall()