feat(*.php, *.psql): deduplicate API code + performance improvements

This commit is contained in:
Cory Dransfeldt 2025-04-22 12:39:42 -07:00
parent cf3dac8a46
commit 4bad005e58
No known key found for this signature in database
31 changed files with 502 additions and 666 deletions

View file

@ -1,6 +1,7 @@
CREATE OR REPLACE VIEW optimized_recent_activity AS
WITH activity_data AS (
SELECT
NULL::bigint AS id,
p.date AS content_date,
p.title,
p.content AS description,
@ -22,6 +23,7 @@ WITH activity_data AS (
UNION ALL
SELECT
NULL::bigint AS id,
l.date AS content_date,
l.title,
l.description,
@ -43,6 +45,7 @@ WITH activity_data AS (
UNION ALL
SELECT
NULL::bigint AS id,
b.date_finished AS content_date,
CONCAT(b.title,
CASE WHEN b.rating IS NOT NULL THEN CONCAT(' (', b.rating, ')') ELSE '' END
@ -67,6 +70,7 @@ WITH activity_data AS (
UNION ALL
SELECT
NULL::bigint AS id,
m.last_watched AS content_date,
CONCAT(m.title,
CASE WHEN m.rating IS NOT NULL THEN CONCAT(' (', m.rating, ')') ELSE '' END
@ -91,6 +95,7 @@ WITH activity_data AS (
UNION ALL
SELECT
c.id,
c.date AS content_date,
CONCAT(c.artist->>'name', ' at ', c.venue->>'name_short') AS title,
c.concert_notes AS description,
@ -104,7 +109,7 @@ WITH activity_data AS (
c.venue->>'latitude' AS venue_lat,
c.venue->>'longitude' AS venue_lon,
c.venue->>'name_short' AS venue_name,
c.notes AS notes,
c.concert_notes AS notes,
'concerts' AS type,
'Concert' AS label
FROM optimized_concerts c