chore: search cleanup

This commit is contained in:
Cory Dransfeldt 2024-10-19 21:21:28 -07:00
parent 19d17f70d2
commit fca18da3f7
No known key found for this signature in database
36 changed files with 71 additions and 60 deletions

View file

@ -0,0 +1,17 @@
CREATE OR REPLACE VIEW three_month_genres AS
SELECT
ol.genre_name,
ol.genre_url,
COUNT(*) AS plays,
json_build_object(
'alt', ol.genre_name,
'subtext', CONCAT(COUNT(*), ' plays')
) AS grid
FROM
optimized_listens ol
WHERE
TO_TIMESTAMP(ol.listened_at) >= NOW() - INTERVAL '3 months'
GROUP BY
ol.genre_name, ol.genre_url
ORDER BY
plays DESC;