chore: fix related books + deduplication

- fixed total plays formatting
- formatted queries
- improved proxy server
This commit is contained in:
Cory Dransfeldt 2024-10-21 12:04:17 -07:00
parent ab50866bb8
commit d2c4c78ff7
No known key found for this signature in database
40 changed files with 985 additions and 1357 deletions

View file

@ -14,7 +14,11 @@ WITH track_stats AS (
WHERE
TO_TIMESTAMP(ol.listened_at) >= NOW() - INTERVAL '30 days'
GROUP BY
ol.track_name, ol.artist_name, ol.album_name, ol.album_art, ol.artist_url
ol.track_name,
ol.artist_name,
ol.album_name,
ol.album_art,
ol.artist_url
)
SELECT
track_name,
@ -24,14 +28,10 @@ SELECT
last_listened,
album_art,
artist_url,
json_build_object(
'title', track_name,
'artist', artist_name,
'url', artist_url,
'plays', plays,
'alt', CONCAT(track_name, ' by ', artist_name),
'subtext', CONCAT(album_name, ' (', plays, ' plays)'),
'percentage', ROUND((plays::decimal / most_played) * 100, 2)
) AS chart
FROM track_stats
ORDER BY plays DESC, last_listened DESC;
json_build_object('title', track_name, 'artist', artist_name, 'url', artist_url, 'plays', plays, 'alt', CONCAT(track_name, ' by ', artist_name), 'subtext', CONCAT(album_name, ' (', plays, ' plays)'), 'percentage', ROUND((plays::decimal / most_played) * 100, 2)) AS chart
FROM
track_stats
ORDER BY
plays DESC,
last_listened DESC;