Skip to content

Commit dd4d46a

Browse files
committed
Improve sorting
Use new icons for sorting up and down. Also fix bug where homepage would show empty dashboard after sorting the same column three times.
1 parent 04dbe17 commit dd4d46a

File tree

3 files changed

+55
-55
lines changed

3 files changed

+55
-55
lines changed

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
2626
<table class="table table-striped table-bordered table-hover">
2727
<thead>
2828
<tr>
29-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"></div>{%elif sortkey == -5%}<div style="float:right;"></div>{%endif%}</th>
30-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"></div>{%elif sortkey == -4%}<div style="float:right;"></div>{%endif%}</th>
29+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"><i class="bi bi-sort-alpha-down"></i></div>{%elif sortkey == -5%}<div style="float:right;"><i class="bi bi-sort-alpha-up"></i></div>{%endif%}</th>
30+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="bi bi-sort-numeric-down"></i></div>{%elif sortkey == -4%}<div style="float:right;"><i class="bi bi-sort-numeric-up"></i></div>{%endif%}</th>
3131
<th>Status</th>
3232
<th>Tags</th>
3333
<th>Ver</th>
34-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"></div>{%elif sortkey == -7%}<div style="float:right;"></div>{%endif%}</th>
35-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"></div>{%elif sortkey == -6%}<div style="float:right;"></div>{%endif%}</th>
34+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"><i class="bi bi-sort-down-alt"></i></div>{%elif sortkey == -7%}<div style="float:right;"><i class="bi bi-sort-up-alt"></i></div>{%endif%}</th>
35+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="bi bi-sort-numeric-down"></i></div>{%elif sortkey == -6%}<div style="float:right;"><i class="bi bi-sort-numeric-up"></i></div>{%endif%}</th>
3636
<th>Author</th>
3737
<th>Reviewers</th>
3838
<th>Committer</th>
39-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"></div>{%elif sortkey == -3%}<div style="float:right;"></div>{%endif%}</th>
40-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"></div>{%elif sortkey == -2%}<div style="float:right;"></div>{%endif%}</th>
39+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"><i class="bi bi-sort-numeric-down-alt"></i></div>{%elif sortkey == -3%}<div style="float:right;"><i class="bi bi-sort-numeric-up-alt"></i></div>{%endif%}</th>
40+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"><i class="bi bi-sort-down"></i></div>{%elif sortkey == -2%}<div style="float:right;"><i class="bi bi-sort-up"></i></div>{%endif%}</th>
4141
{%if user.is_staff%}
4242
<th>Select</th>
4343
{%endif%}

pgcommitfest/commitfest/templates/home.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,25 @@ <h3>{%if user.is_authenticated%}Open patches you are subscribed to{%elif p.is_op
123123
<table class="table table-striped table-bordered table-hover">
124124
<thead>
125125
<tr>
126-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"></div>{%elif sortkey == -5%}<div style="float:right;"></div>{%endif%}</th>
127-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"></div>{%elif sortkey == -4%}<div style="float:right;"></div>{%endif%}</th>
126+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"><i class="bi bi-sort-alpha-down"></i></div>{%elif sortkey == -5%}<div style="float:right;"><i class="bi bi-sort-alpha-up"></i></div>{%endif%}</th>
127+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="bi bi-sort-numeric-down"></i></div>{%elif sortkey == -4%}<div style="float:right;"><i class="bi bi-sort-numeric-up"></i></div>{%endif%}</th>
128128
{%if user.is_authenticated %}
129129
<th>
130130
<a href="#" style="color:#333333;" onclick="return sortpatches(8);">CF</a>
131131
<i class="bi bi-question-circle text-muted" style="font-size: 0.8em; margin-left: 3px;" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" title="Color coding:<br>Green = In Progress<br>Blue = Open<br>Red = Closed"></i>
132-
{%if sortkey == 8%}<div style="float:right;"></div>{%elif sortkey == -8%}<div style="float:right;"></div>{%endif%}
132+
{%if sortkey == 8%}<div style="float:right;"><i class="bi bi-sort-numeric-down"></i></div>{%elif sortkey == -8%}<div style="float:right;"><i class="bi bi-sort-numeric-up"></i></div>{%endif%}
133133
</th>
134134
{%endif%}
135135
<th>Status</th>
136136
<th>Tags</th>
137137
<th>Ver</th>
138-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"></div>{%elif sortkey == -7%}<div style="float:right;"></div>{%endif%}</th>
139-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"></div>{%elif sortkey == -6%}<div style="float:right;"></div>{%endif%}</th>
138+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"><i class="bi bi-sort-down-alt"></i></div>{%elif sortkey == -7%}<div style="float:right;"><i class="bi bi-sort-up-alt"></i></div>{%endif%}</th>
139+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="bi bi-sort-numeric-down"></i></div>{%elif sortkey == -6%}<div style="float:right;"><i class="bi bi-sort-numeric-up"></i></div>{%endif%}</th>
140140
<th>Author</th>
141141
<th>Reviewers</th>
142142
<th>Committer</th>
143-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"></div>{%elif sortkey == -3%}<div style="float:right;"></div>{%endif%}</th>
144-
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"></div>{%elif sortkey == -2%}<div style="float:right;"></div>{%endif%}</th>
143+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"><i class="bi bi-sort-numeric-down-alt"></i></div>{%elif sortkey == -3%}<div style="float:right;"><i class="bi bi-sort-numeric-up-alt"></i></div>{%endif%}</th>
144+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"><i class="bi bi-sort-down"></i></div>{%elif sortkey == -2%}<div style="float:right;"><i class="bi bi-sort-up"></i></div>{%endif%}</th>
145145
</tr>
146146
</thead>
147147
<tbody>

pgcommitfest/commitfest/views.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -82,50 +82,50 @@ def home(request):
8282
form = CommitFestFilterForm(request.GET)
8383
patch_list = patchlist(request, cf, personalized=True)
8484

85-
if not patch_list.redirect:
86-
# Get stats related to user for current commitfest (same as me() view)
87-
curs.execute(
88-
"""SELECT
89-
ps.status, ps.statusstring, count(*)
90-
FROM commitfest_patchoncommitfest poc
91-
INNER JOIN commitfest_patch p ON p.id = poc.patch_id
92-
INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status
93-
WHERE
94-
ps.status = ANY(%(openstatuses)s)
95-
AND (
96-
EXISTS (
97-
SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s
98-
)
99-
OR EXISTS (
100-
SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(user_id)s
101-
)
102-
OR p.committer_id=%(user_id)s
85+
if patch_list.redirect:
86+
return patch_list.redirect
87+
88+
# Get stats related to user for current commitfest (same as me() view)
89+
curs.execute(
90+
"""SELECT
91+
ps.status, ps.statusstring, count(*)
92+
FROM commitfest_patchoncommitfest poc
93+
INNER JOIN commitfest_patch p ON p.id = poc.patch_id
94+
INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status
95+
WHERE
96+
ps.status = ANY(%(openstatuses)s)
97+
AND (
98+
EXISTS (
99+
SELECT 1 FROM commitfest_patch_reviewers cpr WHERE cpr.patch_id=p.id AND cpr.user_id=%(user_id)s
103100
)
104-
GROUP BY ps.status ORDER BY ps.sortkey""",
105-
{
106-
"user_id": request.user.id,
107-
"openstatuses": PatchOnCommitFest.OPEN_STATUSES,
108-
},
109-
)
110-
statussummary = curs.fetchall()
111-
112-
context.update(
113-
{
114-
"show_dashboard": True,
115-
"form": form,
116-
"patches": patch_list.patches,
117-
"statussummary": statussummary,
118-
"all_tags": {t.id: t for t in Tag.objects.all()},
119-
"has_filter": patch_list.has_filter,
120-
"grouping": patch_list.sortkey == 0,
121-
"sortkey": patch_list.sortkey,
122-
"openpatchids": [
123-
p["id"] for p in patch_list.patches if p["is_open"]
124-
],
125-
"userprofile": getattr(request.user, "userprofile", UserProfile()),
126-
"is_experienced_user": is_experienced_user,
127-
}
101+
OR EXISTS (
102+
SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id AND cpa.user_id=%(user_id)s
103+
)
104+
OR p.committer_id=%(user_id)s
128105
)
106+
GROUP BY ps.status ORDER BY ps.sortkey""",
107+
{
108+
"user_id": request.user.id,
109+
"openstatuses": PatchOnCommitFest.OPEN_STATUSES,
110+
},
111+
)
112+
statussummary = curs.fetchall()
113+
114+
context.update(
115+
{
116+
"show_dashboard": True,
117+
"form": form,
118+
"patches": patch_list.patches,
119+
"statussummary": statussummary,
120+
"all_tags": {t.id: t for t in Tag.objects.all()},
121+
"has_filter": patch_list.has_filter,
122+
"grouping": patch_list.sortkey == 0,
123+
"sortkey": patch_list.sortkey,
124+
"openpatchids": [p["id"] for p in patch_list.patches if p["is_open"]],
125+
"userprofile": getattr(request.user, "userprofile", UserProfile()),
126+
"is_experienced_user": is_experienced_user,
127+
}
128+
)
129129

130130
return render(request, "home.html", context)
131131

0 commit comments

Comments
 (0)