feat: initial view queries
This commit is contained in:
parent
8f44ce9bdd
commit
08e2c2ff3f
23 changed files with 1282 additions and 10 deletions
36
views/content/links.psql
Normal file
36
views/content/links.psql
Normal file
|
@ -0,0 +1,36 @@
|
|||
CREATE OR REPLACE VIEW optimized_links AS
|
||||
SELECT
|
||||
l.id,
|
||||
l.title,
|
||||
l.date,
|
||||
l.description,
|
||||
l.link,
|
||||
a.mastodon,
|
||||
a.name,
|
||||
json_build_object(
|
||||
'name', a.name,
|
||||
'url', a.url,
|
||||
'mastodon', a.mastodon
|
||||
) AS author,
|
||||
'link' AS type,
|
||||
|
||||
(
|
||||
SELECT array_agg(t.name)
|
||||
FROM links_tags lt
|
||||
LEFT JOIN tags t ON lt.tags_id = t.id
|
||||
WHERE lt.links_id = l.id
|
||||
) AS tags,
|
||||
|
||||
json_build_object(
|
||||
'title', CONCAT(l.title, ' via ', a.name),
|
||||
'url', l.link,
|
||||
'description', l.description,
|
||||
'date', l.date
|
||||
) AS feed
|
||||
|
||||
FROM
|
||||
links l
|
||||
JOIN
|
||||
authors a ON l.author = a.id
|
||||
ORDER BY
|
||||
l.date DESC;
|
Reference in a new issue