feat: view queries in; media updated

This commit is contained in:
Cory Dransfeldt 2024-10-12 16:01:02 -07:00
parent 08e2c2ff3f
commit 057d75f863
No known key found for this signature in database
49 changed files with 578 additions and 353 deletions

View file

@ -0,0 +1,22 @@
CREATE OR REPLACE VIEW three_month_artists AS
SELECT
ol.artist_name,
COUNT(*) AS plays,
ol.artist_art,
ol.artist_url,
ARRAY_AGG(DISTINCT ol.genre_name) AS genres,
json_build_object(
'title', ol.artist_name,
'image', ol.artist_art,
'url', ol.artist_url,
'alt', CONCAT(COUNT(*), ' plays of ', ol.artist_name),
'subtext', CONCAT(COUNT(*), ' plays')
) AS grid
FROM
optimized_listens ol
WHERE
TO_TIMESTAMP(ol.listened_at) >= NOW() - INTERVAL '3 months'
GROUP BY
ol.artist_name, ol.artist_art, ol.artist_url
ORDER BY
plays DESC;