mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 20:11:50 -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
|
|
@ -81,6 +81,26 @@ FROM (
|
|||
ORDER BY x.listen_count DESC, x.id
|
||||
LIMIT $3 OFFSET $4;
|
||||
|
||||
-- name: GetArtistAllTimeRank :one
|
||||
SELECT
|
||||
artist_id,
|
||||
rank
|
||||
FROM (
|
||||
SELECT
|
||||
x.artist_id,
|
||||
RANK() OVER (ORDER BY x.listen_count DESC) AS rank
|
||||
FROM (
|
||||
SELECT
|
||||
at.artist_id,
|
||||
COUNT(*) AS listen_count
|
||||
FROM listens l
|
||||
JOIN tracks t ON l.track_id = t.id
|
||||
JOIN artist_tracks at ON t.id = at.track_id
|
||||
GROUP BY at.artist_id
|
||||
) x
|
||||
)
|
||||
WHERE artist_id = $1;
|
||||
|
||||
-- name: CountTopArtists :one
|
||||
SELECT COUNT(DISTINCT at.artist_id) AS total_count
|
||||
FROM listens l
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue