mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-23 04:21:51 -07:00
add all time rank to item pages
This commit is contained in:
parent
d08e05220f
commit
89161b5586
17 changed files with 274 additions and 181 deletions
|
|
@ -124,6 +124,24 @@ FROM (
|
|||
ORDER BY x.listen_count DESC, x.id
|
||||
LIMIT $3 OFFSET $4;
|
||||
|
||||
-- name: GetTrackAllTimeRank :one
|
||||
SELECT
|
||||
id,
|
||||
rank
|
||||
FROM (
|
||||
SELECT
|
||||
x.id,
|
||||
RANK() OVER (ORDER BY x.listen_count DESC) AS rank
|
||||
FROM (
|
||||
SELECT
|
||||
t.id,
|
||||
COUNT(*) AS listen_count
|
||||
FROM listens l
|
||||
JOIN tracks_with_title t ON l.track_id = t.id
|
||||
GROUP BY t.id) x
|
||||
) y
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: CountTopTracks :one
|
||||
SELECT COUNT(DISTINCT l.track_id) AS total_count
|
||||
FROM listens l
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue