chore: search cleanup
This commit is contained in:
parent
19d17f70d2
commit
fca18da3f7
36 changed files with 71 additions and 60 deletions
22
queries/views/globals/index.psql
Normal file
22
queries/views/globals/index.psql
Normal file
|
@ -0,0 +1,22 @@
|
|||
CREATE OR REPLACE VIEW optimized_globals AS
|
||||
SELECT
|
||||
g.site_name,
|
||||
g.site_description,
|
||||
g.intro,
|
||||
g.author,
|
||||
g.email,
|
||||
g.mastodon,
|
||||
g.url,
|
||||
g.cdn_url,
|
||||
g.theme_color,
|
||||
g.site_type,
|
||||
g.locale,
|
||||
g.lang,
|
||||
g.webfinger_username,
|
||||
g.webfinger_hostname,
|
||||
CONCAT('/', df.filename_disk) AS avatar,
|
||||
CONCAT('/', df2.filename_disk) AS avatar_transparent
|
||||
FROM
|
||||
globals g
|
||||
LEFT JOIN directus_files df ON g.avatar = df.id
|
||||
LEFT JOIN directus_files df2 ON g.avatar_transparent = df2.id
|
14
queries/views/globals/nav.psql
Normal file
14
queries/views/globals/nav.psql
Normal file
|
@ -0,0 +1,14 @@
|
|||
CREATE OR REPLACE VIEW optimized_navigation AS
|
||||
SELECT
|
||||
n.id,
|
||||
n.menu_location,
|
||||
n.permalink,
|
||||
n.icon,
|
||||
n.title,
|
||||
n.sort,
|
||||
p.title AS page_title,
|
||||
p.permalink AS page_permalink
|
||||
FROM
|
||||
navigation n
|
||||
LEFT JOIN
|
||||
pages p ON n.pages = p.id;
|
63
queries/views/globals/pages.psql
Normal file
63
queries/views/globals/pages.psql
Normal file
|
@ -0,0 +1,63 @@
|
|||
CREATE OR REPLACE VIEW optimized_pages AS
|
||||
SELECT
|
||||
p.id,
|
||||
p.title,
|
||||
p.permalink,
|
||||
p.description,
|
||||
CONCAT('/', df.filename_disk) AS open_graph_image,
|
||||
p.updated,
|
||||
|
||||
(
|
||||
SELECT json_agg(
|
||||
CASE
|
||||
WHEN pb.collection = 'youtube_player' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'url', yp.url
|
||||
)
|
||||
WHEN pb.collection = 'github_banner' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'url', gb.url
|
||||
)
|
||||
WHEN pb.collection = 'npm_banner' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'url', nb.url,
|
||||
'command', nb.command
|
||||
)
|
||||
WHEN pb.collection = 'rss_banner' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'url', rb.url,
|
||||
'text', rb.text
|
||||
)
|
||||
WHEN pb.collection = 'hero' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'image', CONCAT('/', df_hero.filename_disk),
|
||||
'alt', h.alt_text
|
||||
)
|
||||
WHEN pb.collection = 'markdown' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'text', md.text
|
||||
)
|
||||
WHEN pb.collection = 'divider' THEN json_build_object(
|
||||
'type', pb.collection,
|
||||
'markup', d.markup
|
||||
)
|
||||
ELSE json_build_object('type', pb.collection)
|
||||
END
|
||||
ORDER BY pb.sort)
|
||||
FROM pages_blocks pb
|
||||
LEFT JOIN youtube_player yp ON pb.collection = 'youtube_player' AND yp.id = pb.item::INTEGER
|
||||
LEFT JOIN github_banner gb ON pb.collection = 'github_banner' AND gb.id = pb.item::INTEGER
|
||||
LEFT JOIN npm_banner nb ON pb.collection = 'npm_banner' AND nb.id = pb.item::INTEGER
|
||||
LEFT JOIN rss_banner rb ON pb.collection = 'rss_banner' AND rb.id = pb.item::INTEGER
|
||||
LEFT JOIN hero h ON pb.collection = 'hero' AND h.id = pb.item::INTEGER
|
||||
LEFT JOIN directus_files df_hero ON h.image = df_hero.id
|
||||
LEFT JOIN markdown md ON pb.collection = 'markdown' AND md.id = pb.item::INTEGER
|
||||
LEFT JOIN divider d ON pb.collection = 'divider' AND d.id = pb.item::INTEGER
|
||||
WHERE pb.pages_id = p.id
|
||||
) AS blocks
|
||||
FROM
|
||||
pages p
|
||||
LEFT JOIN
|
||||
directus_files df ON p.open_graph_image = df.id
|
||||
GROUP BY
|
||||
p.id, df.filename_disk;
|
Reference in a new issue