Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse sorting on commitfest page #33

Merged
merged 4 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion media/commitfest/js/commitfest.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ function flagCommitted(committer) {
}

function sortpatches(sortby) {
if ($("#id_sortkey").val() === sortby) {
const sortkey = $("#id_sortkey").val();
if (sortkey === sortby) {
$("#id_sortkey").val(-sortby);
} else if (-sortkey === sortby) {
$("#id_sortkey").val(0);
} else {
$("#id_sortkey").val(sortby);
Expand Down
12 changes: 6 additions & 6 deletions pgcommitfest/commitfest/templates/commitfest.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(5);">Patch</a>{%if sortkey == 5%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -5%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th>Status</th>
<th>Ver</th>
<th>CI status</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th>Author</th>
<th>Reviewers</th>
<th>Committer</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(1);">Latest activity</a>{%if sortkey == 1%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(3);">Num cfs</a>{%if sortkey == 3%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -3%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(1);">Latest activity</a>{%if sortkey == 1%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -1%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
<th><a href="#" style="color:#333333;" onclick="return sortpatches(2);">Latest mail</a>{%if sortkey == 2%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -2%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
{%if user.is_staff%}
<th>Select</th>
{%endif%}
Expand Down
12 changes: 12 additions & 0 deletions pgcommitfest/commitfest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,30 @@ def commitfest(request, cfid):

if sortkey == 1:
orderby_str = "modified, created"
elif sortkey == -1:
orderby_str = "modified DESC, created DESC"
elif sortkey == 2:
orderby_str = "lastmail, created"
elif sortkey == -2:
orderby_str = "lastmail DESC, created DESC"
elif sortkey == 3:
orderby_str = "num_cfs DESC, modified, created"
elif sortkey == -3:
orderby_str = "num_cfs ASC, modified DESC, created DESC"
elif sortkey == 4:
orderby_str = "p.id"
elif sortkey == -4:
orderby_str = "p.id DESC"
elif sortkey == 5:
orderby_str = "p.name, created"
elif sortkey == -5:
orderby_str = "p.name DESC, created DESC"
elif sortkey == 6:
orderby_str = (
"branch.all_additions + branch.all_deletions NULLS LAST, created"
)
elif sortkey == -6:
orderby_str = "branch.all_additions + branch.all_deletions DESC NULLS LAST, created DESC"
else:
orderby_str = "p.id"
sortkey = 0
Expand Down