fix(oembed.sql): surface correct open graph images

This commit is contained in:
Cory Dransfeldt 2025-05-24 19:03:45 -07:00
parent 3dac23b171
commit 53e453ba04
No known key found for this signature in database
6 changed files with 24 additions and 44 deletions

View file

@ -96,7 +96,18 @@ SELECT
LEFT JOIN posts p ON pg.posts_id = p.id
LEFT JOIN directus_files df_post ON p.image = df_post.id
WHERE pg.genres_id = g.id
) AS posts
) AS posts,
json_build_object(
'open_graph_image', (
SELECT CONCAT('/', df_artist.filename_disk)
FROM artists a
LEFT JOIN directus_files df_artist ON a.art = df_artist.id
WHERE a.genres = g.id
AND df_artist.filename_disk IS NOT NULL AND df_artist.filename_disk != ''
ORDER BY a.total_plays DESC
LIMIT 1
)
) AS metadata
FROM genres g
CROSS JOIN optimized_globals globals
ORDER BY g.id ASC;