From c79605de2306083ece4f6e4161385c52b68a94f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Tamargo?= Date: Mon, 25 Nov 2024 18:21:55 +0100 Subject: [PATCH] MBS-13832: Don't skip PDF files for frontiest check We originally skipped PDFs because they didn't use to support thumbnails (making them bad choices for the sidebar and the like). That changed many years ago though, and especially for events, it's not uncommon for the frontiest image to be a PDF. --- admin/sql/caa/CreateViews.sql | 1 - admin/sql/eaa/CreateViews.sql | 1 - admin/sql/updates/20241125-mbs-13832.sql | 46 +++++++++++++++++++ admin/sql/updates/schema-change/30.all.sql | 52 ++++++++++++++++++++++ upgrade.json | 5 +++ 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 admin/sql/updates/20241125-mbs-13832.sql create mode 100644 admin/sql/updates/schema-change/30.all.sql diff --git a/admin/sql/caa/CreateViews.sql b/admin/sql/caa/CreateViews.sql index c9cbac3fd31..e005e2c9855 100644 --- a/admin/sql/caa/CreateViews.sql +++ b/admin/sql/caa/CreateViews.sql @@ -11,7 +11,6 @@ SELECT cover_art.*, JOIN cover_art_archive.cover_art ca_front USING (id) WHERE ca_front.release = cover_art.release AND type_id = 1 - AND mime_type != 'application/pdf' ORDER BY ca_front.ordering LIMIT 1), FALSE) AS is_front, coalesce(cover_art.id = (SELECT id FROM cover_art_archive.cover_art_type diff --git a/admin/sql/eaa/CreateViews.sql b/admin/sql/eaa/CreateViews.sql index 56f9aaae1b6..cb87fc49b48 100644 --- a/admin/sql/eaa/CreateViews.sql +++ b/admin/sql/eaa/CreateViews.sql @@ -11,7 +11,6 @@ SELECT event_art.*, JOIN event_art_archive.event_art ea_front USING (id) WHERE ea_front.event = event_art.event AND type_id = 1 - AND mime_type != 'application/pdf' ORDER BY ea_front.ordering LIMIT 1), FALSE) AS is_front, array(SELECT art_type.name diff --git a/admin/sql/updates/20241125-mbs-13832.sql b/admin/sql/updates/20241125-mbs-13832.sql new file mode 100644 index 00000000000..e6d8e14a9ca --- /dev/null +++ b/admin/sql/updates/20241125-mbs-13832.sql @@ -0,0 +1,46 @@ +\set ON_ERROR_STOP 1 + +BEGIN; + +-- CAA view +CREATE OR REPLACE VIEW index_listing AS +SELECT cover_art.*, + (edit.close_time IS NOT NULL) AS approved, + coalesce(cover_art.id = (SELECT id FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.cover_art ca_front USING (id) + WHERE ca_front.release = cover_art.release + AND type_id = 1 + ORDER BY ca_front.ordering + LIMIT 1), FALSE) AS is_front, + coalesce(cover_art.id = (SELECT id FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.cover_art ca_front USING (id) + WHERE ca_front.release = cover_art.release + AND type_id = 2 + ORDER BY ca_front.ordering + LIMIT 1), FALSE) AS is_back, + array(SELECT art_type.name + FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.art_type ON cover_art_type.type_id = art_type.id + WHERE cover_art_type.id = cover_art.id) AS types +FROM cover_art_archive.cover_art +LEFT JOIN musicbrainz.edit ON edit.id = cover_art.edit; + +-- EAA view +CREATE OR REPLACE VIEW index_listing AS +SELECT event_art.*, + (edit.close_time IS NOT NULL) AS approved, + coalesce(event_art.id = (SELECT id FROM event_art_archive.event_art_type + JOIN event_art_archive.event_art ea_front USING (id) + WHERE ea_front.event = event_art.event + AND type_id = 1 + ORDER BY ea_front.ordering + LIMIT 1), FALSE) AS is_front, + array(SELECT art_type.name + FROM event_art_archive.event_art_type + JOIN event_art_archive.art_type ON event_art_type.type_id = art_type.id + WHERE event_art_type.id = event_art.id) AS types +FROM event_art_archive.event_art +LEFT JOIN musicbrainz.edit ON edit.id = event_art.edit; + + +COMMIT; diff --git a/admin/sql/updates/schema-change/30.all.sql b/admin/sql/updates/schema-change/30.all.sql new file mode 100644 index 00000000000..4344c8a3621 --- /dev/null +++ b/admin/sql/updates/schema-change/30.all.sql @@ -0,0 +1,52 @@ +-- Generated by CompileSchemaScripts.pl from: +-- 20241125-mbs-13832.sql +\set ON_ERROR_STOP 1 +BEGIN; +SET search_path = musicbrainz, public; +SET LOCAL statement_timeout = 0; +-------------------------------------------------------------------------------- +SELECT '20241125-mbs-13832.sql'; + + +-- CAA view +CREATE OR REPLACE VIEW index_listing AS +SELECT cover_art.*, + (edit.close_time IS NOT NULL) AS approved, + coalesce(cover_art.id = (SELECT id FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.cover_art ca_front USING (id) + WHERE ca_front.release = cover_art.release + AND type_id = 1 + ORDER BY ca_front.ordering + LIMIT 1), FALSE) AS is_front, + coalesce(cover_art.id = (SELECT id FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.cover_art ca_front USING (id) + WHERE ca_front.release = cover_art.release + AND type_id = 2 + ORDER BY ca_front.ordering + LIMIT 1), FALSE) AS is_back, + array(SELECT art_type.name + FROM cover_art_archive.cover_art_type + JOIN cover_art_archive.art_type ON cover_art_type.type_id = art_type.id + WHERE cover_art_type.id = cover_art.id) AS types +FROM cover_art_archive.cover_art +LEFT JOIN musicbrainz.edit ON edit.id = cover_art.edit; + +-- EAA view +CREATE OR REPLACE VIEW index_listing AS +SELECT event_art.*, + (edit.close_time IS NOT NULL) AS approved, + coalesce(event_art.id = (SELECT id FROM event_art_archive.event_art_type + JOIN event_art_archive.event_art ea_front USING (id) + WHERE ea_front.event = event_art.event + AND type_id = 1 + ORDER BY ea_front.ordering + LIMIT 1), FALSE) AS is_front, + array(SELECT art_type.name + FROM event_art_archive.event_art_type + JOIN event_art_archive.art_type ON event_art_type.type_id = art_type.id + WHERE event_art_type.id = event_art.id) AS types +FROM event_art_archive.event_art +LEFT JOIN musicbrainz.edit ON edit.id = event_art.edit; + + +COMMIT; diff --git a/upgrade.json b/upgrade.json index 80853eb68d6..549fd24ef05 100644 --- a/upgrade.json +++ b/upgrade.json @@ -230,5 +230,10 @@ "20240223-mbs-13421-fks.sql", "20240319-mbs-13514.sql" ] + }, + "30": { + "all": [ + "20241125-mbs-13832.sql" + ] } }