Skip to content

Commit

Permalink
site: leaderboard: Fix intra-page sorting
Browse files Browse the repository at this point in the history
While overall sorting might be correct, leaderboard results within a page
are not sorted correctly.  Fix this by ordering again after joining.

Fixes: efcdaf0 ("Add leaderboard")
Signed-off-by: Sean Anderson <[email protected]>
  • Loading branch information
Forty-Bot committed Apr 13, 2024
1 parent 9acd45e commit 4edf9ff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions trends/site/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def leaderboard():

db = get_db()
leaderboard = db.cursor()
leaderboard.execute("""SELECT
leaderboard.execute(f"""SELECT
name,
avatarhash,
steamid64,
Expand Down Expand Up @@ -143,15 +143,15 @@ def leaderboard():
sum(hits) * 1.0 / nullif(sum(shots), 0) AS acc
FROM leaderboard_cube
WHERE grouping = %(grouping)s
{}
{}
{filter_clauses}
{cube_clauses}
GROUP BY playerid
ORDER BY {} NULLS LAST
ORDER BY {order_clause} NULLS LAST
LIMIT %(limit)s OFFSET %(offset)s
) AS leaderboard
LEFT JOIN player USING (playerid)
LEFT JOIN name USING (nameid);"""
.format(filter_clauses, cube_clauses, order_clause),
LEFT JOIN name USING (nameid)
ORDER BY {order_clause};""",
{ **filters, 'grouping': grouping, 'limit': limit, 'offset': offset })
resp = flask.make_response(flask.render_template("leaderboard.html",
leaderboard=leaderboard.fetchall()))
Expand Down

0 comments on commit 4edf9ff

Please sign in to comment.