This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/queries/views/media/music/album-releases.psql

33 lines
No EOL
792 B
Text

CREATE OR REPLACE VIEW optimized_album_releases AS
SELECT
a.name AS title,
a.release_date,
a.release_link AS url,
a.total_plays,
CONCAT('/', df.filename_disk) AS image,
'album-release' AS type,
json_build_object(
'name', ar.name_string,
'url', ar.slug,
'description', ar.description
) AS artist,
EXTRACT(EPOCH FROM a.release_date) AS release_timestamp,
json_build_object(
'title', a.name,
'image', CONCAT('/', df.filename_disk),
'url', a.release_link,
'alt', CONCAT(a.name, ' by ', ar.name_string),
'subtext', CONCAT(ar.name_string, ' / ', TO_CHAR(a.release_date, 'Mon FMDD, YYYY'))
) AS grid
FROM
albums a
LEFT JOIN
directus_files df ON a.art = df.id
LEFT JOIN
artists ar ON a.artist = ar.id
WHERE
a.release_date IS NOT NULL;