fix(oembed.sql): return top artist image for oembed on genre pages

This commit is contained in:
Cory Dransfeldt 2025-05-10 19:03:08 -07:00
parent dd8369af04
commit 52257f50a1
No known key found for this signature in database
3 changed files with 12 additions and 7 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd.dev",
"version": "4.0.2",
"version": "4.0.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd.dev",
"version": "4.0.2",
"version": "4.0.3",
"license": "MIT",
"dependencies": {
"html-minifier-terser": "7.2.0",

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "4.0.2",
"version": "4.0.3",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"engines": {

View file

@ -49,10 +49,15 @@ WITH oembed_data AS (
CURRENT_TIMESTAMP AS content_date
FROM optimized_genres g
LEFT JOIN LATERAL (
SELECT ar.image
FROM optimized_artists ar
WHERE (ar.genre->>'id')::bigint = g.id
ORDER BY ar.total_plays DESC
SELECT
CASE
WHEN df.filename_disk IS NOT NULL AND df.filename_disk != '' THEN CONCAT('/', df.filename_disk)
ELSE (SELECT avatar FROM optimized_globals LIMIT 1)
END AS image
FROM artists a
LEFT JOIN directus_files df ON a.art = df.id
WHERE a.genres = g.id
ORDER BY a.total_plays DESC
LIMIT 1
) top_artist ON true
UNION ALL