chore: remove old filters, hardcoded types, old post status from view

This commit is contained in:
Cory Dransfeldt 2024-10-13 15:51:27 -07:00
parent ffea333d55
commit 76a172bb74
No known key found for this signature in database
15 changed files with 15 additions and 48 deletions

View file

@ -1,20 +1,4 @@
import { DateTime } from 'luxon'
export default { export default {
isoDateOnly: (date, separator) => {
let d = new Date(date)
let month = '' + (d.getMonth() + 1)
let day = '' + d.getDate()
let year = d.getFullYear()
if (month.length < 2) month = '0' + month
if (day.length < 2) day = '0' + day
return [year, month, day].join(separator)
},
oldPost: (date) => {
return DateTime.now().diff(DateTime.fromJSDate(new Date(date)), 'years').years > 3
},
stringToRFC822Date: (dateString) => { stringToRFC822Date: (dateString) => {
const date = new Date(Date.parse(dateString)) const date = new Date(Date.parse(dateString))
const dayStrings = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] const dayStrings = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']

View file

@ -142,7 +142,7 @@
"inLanguage": "{{ globals.locale }}", "inLanguage": "{{ globals.locale }}",
"publisher": { "@type": "{{ globals.site_type }}", "name": "{{ globals.author }}", "url": "{{ globals.url }}" }, "publisher": { "@type": "{{ globals.site_type }}", "name": "{{ globals.author }}", "url": "{{ globals.url }}" },
"author": { "@type": "Person", "name": "{{ globals.author }}" }, "author": { "@type": "Person", "name": "{{ globals.author }}" },
"datePublished": "{{ page.date | isoDateOnly: '.' }}" "datePublished": "{{ page.date | date: "%Y.%m.%d" }}"
} }
{%- endif -%} {%- endif -%}
] ]

View file

@ -1,4 +1,3 @@
{%- assign isOldPost = date | oldPost -%}
{%- if isOldPost -%} {%- if isOldPost -%}
<div class="banner old-post"> <div class="banner old-post">
<p>{% tablericon "clock-x" %}This post is over 3 years old. I've probably changed my mind since it was written and it <em>could</em> be out of date.</p> <p>{% tablericon "clock-x" %}This post is over 3 years old. I've probably changed my mind since it was written and it <em>could</em> be out of date.</p>

View file

@ -12,7 +12,7 @@ schema: artist
{{ artist.name }} / {{ artist.country }} {{ artist.name }} / {{ artist.country }}
{%- endcapture -%} {%- endcapture -%}
{%- capture playLabel -%} {%- capture playLabel -%}
{%- if artist.totalPlays == 1 -%} {%- if artist.total_plays == 1 -%}
play play
{%- else -%} {%- else -%}
plays plays
@ -105,8 +105,8 @@ schema: artist
{% for album in artist.albums %} {% for album in artist.albums %}
<tr> <tr>
<td>{{ album.name }}</td> <td>{{ album.name }}</td>
<td>{{ album.totalPlays }}</td> <td>{{ album.total_plays }}</td>
<td>{{ album.releaseYear }}</td> <td>{{ album.release_year }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View file

@ -18,7 +18,7 @@ schema: blog
{{ post.title }} {{ post.title }}
</h3> </h3>
<div> <div>
{% render "partials/blocks/banners/old-post.liquid", date:post.date %} {% render "partials/blocks/banners/old-post.liquid", isOldPost:post.old_post %}
{%- if post.image -%} {%- if post.image -%}
<img <img
srcset=" srcset="

View file

@ -8,6 +8,7 @@ SELECT
p.featured, p.featured,
p.slug AS url, p.slug AS url,
p.mastodon_url, p.mastodon_url,
CASE CASE
WHEN df.filename_disk IS NOT NULL AND df.filename_disk != '' AND df.filename_disk != '/' WHEN df.filename_disk IS NOT NULL AND df.filename_disk != '' AND df.filename_disk != '/'
THEN CONCAT('/', df.filename_disk) THEN CONCAT('/', df.filename_disk)
@ -15,6 +16,11 @@ SELECT
END AS image, END AS image,
p.image_alt, p.image_alt,
CASE
WHEN EXTRACT(YEAR FROM AGE(CURRENT_DATE, p.date)) > 3 THEN TRUE
ELSE FALSE
END AS old_post,
( (
SELECT json_agg( SELECT json_agg(
CASE CASE

View file

@ -2,7 +2,6 @@ CREATE OR REPLACE VIEW optimized_all_activity AS
WITH feed_data AS ( WITH feed_data AS (
SELECT SELECT
p.date AS content_date, p.date AS content_date,
'post' AS content_type,
p.title, p.title,
p.description, p.description,
CONCAT('https://coryd.dev', p.url) AS url, CONCAT('https://coryd.dev', p.url) AS url,
@ -21,7 +20,6 @@ WITH feed_data AS (
SELECT SELECT
l.date AS content_date, l.date AS content_date,
'link' AS content_type,
l.title, l.title,
l.description, l.description,
l.link AS url, l.link AS url,
@ -40,7 +38,6 @@ WITH feed_data AS (
SELECT SELECT
b.date_finished AS content_date, b.date_finished AS content_date,
'book' AS content_type,
b.title, b.title,
b.description, b.description,
CONCAT('https://coryd.dev', b.url) AS url, CONCAT('https://coryd.dev', b.url) AS url,
@ -64,7 +61,6 @@ WITH feed_data AS (
SELECT SELECT
m.last_watched AS content_date, m.last_watched AS content_date,
'movie' AS content_type,
m.title, m.title,
m.description, m.description,
CONCAT('https://coryd.dev', m.url) AS url, CONCAT('https://coryd.dev', m.url) AS url,

View file

@ -1,7 +1,6 @@
CREATE OR REPLACE VIEW optimized_search_index AS CREATE OR REPLACE VIEW optimized_search_index AS
WITH search_data AS ( WITH search_data AS (
SELECT SELECT
'post' AS content_type,
CONCAT('📝 ', p.title) AS title, CONCAT('📝 ', p.title) AS title,
CONCAT('https://coryd.dev', p.url) AS url, CONCAT('https://coryd.dev', p.url) AS url,
p.tags, p.tags,
@ -12,7 +11,6 @@ WITH search_data AS (
UNION ALL UNION ALL
SELECT SELECT
'link' AS content_type,
CONCAT('🔗 ', l.title, ' via ', l.name) AS title, CONCAT('🔗 ', l.title, ' via ', l.name) AS title,
l.link AS url, l.link AS url,
l.tags, l.tags,
@ -23,7 +21,6 @@ WITH search_data AS (
UNION ALL UNION ALL
SELECT SELECT
'book' AS content_type,
CASE CASE
WHEN b.rating IS NOT NULL THEN CONCAT('📖 ', b.title, ' (', b.rating, ')') WHEN b.rating IS NOT NULL THEN CONCAT('📖 ', b.title, ' (', b.rating, ')')
ELSE CONCAT('📖 ', b.title) ELSE CONCAT('📖 ', b.title)
@ -38,7 +35,6 @@ WITH search_data AS (
UNION ALL UNION ALL
SELECT SELECT
'movie' AS content_type,
CASE CASE
WHEN m.rating IS NOT NULL THEN CONCAT('🎥 ', m.title, ' (', m.rating, ')') WHEN m.rating IS NOT NULL THEN CONCAT('🎥 ', m.title, ' (', m.rating, ')')
ELSE CONCAT('🎥 ', m.title) ELSE CONCAT('🎥 ', m.title)
@ -53,7 +49,6 @@ WITH search_data AS (
UNION ALL UNION ALL
SELECT SELECT
'artist' AS content_type,
CONCAT('🎧 ', ar.name, ' - ', ar.genre_name) AS title, CONCAT('🎧 ', ar.name, ' - ', ar.genre_name) AS title,
CONCAT('https://coryd.dev', ar.url) AS url, CONCAT('https://coryd.dev', ar.url) AS url,
ARRAY[ar.genre_name] AS tags, ARRAY[ar.genre_name] AS tags,
@ -64,7 +59,6 @@ WITH search_data AS (
UNION ALL UNION ALL
SELECT SELECT
'genre' AS content_type,
CONCAT('🎵 ', g.name) AS title, CONCAT('🎵 ', g.name) AS title,
CONCAT('https://coryd.dev', g.url) AS url, CONCAT('https://coryd.dev', g.url) AS url,
NULL AS tags, NULL AS tags,

View file

@ -2,7 +2,6 @@ CREATE OR REPLACE VIEW optimized_sitemap AS
WITH sitemap_data AS ( WITH sitemap_data AS (
SELECT SELECT
p.date AS content_date, p.date AS content_date,
'post' AS content_type,
p.title, p.title,
CONCAT('https://coryd.dev', p.url) AS url CONCAT('https://coryd.dev', p.url) AS url
FROM optimized_posts p FROM optimized_posts p
@ -11,7 +10,6 @@ WITH sitemap_data AS (
SELECT SELECT
b.date_finished AS content_date, b.date_finished AS content_date,
'book' AS content_type,
b.title, b.title,
CONCAT('https://coryd.dev', b.url) AS url CONCAT('https://coryd.dev', b.url) AS url
FROM optimized_books b FROM optimized_books b
@ -21,7 +19,6 @@ WITH sitemap_data AS (
SELECT SELECT
m.last_watched AS content_date, m.last_watched AS content_date,
'movie' AS content_type,
m.title, m.title,
CONCAT('https://coryd.dev', m.url) AS url CONCAT('https://coryd.dev', m.url) AS url
FROM optimized_movies m FROM optimized_movies m
@ -31,7 +28,6 @@ WITH sitemap_data AS (
SELECT SELECT
NULL AS content_date, NULL AS content_date,
'artist' AS content_type,
ar.name AS title, ar.name AS title,
CONCAT('https://coryd.dev', ar.url) AS url CONCAT('https://coryd.dev', ar.url) AS url
FROM optimized_artists ar FROM optimized_artists ar
@ -40,7 +36,6 @@ WITH sitemap_data AS (
SELECT SELECT
NULL AS content_date, NULL AS content_date,
'genre' AS content_type,
g.name AS title, g.name AS title,
CONCAT('https://coryd.dev', g.url) AS url CONCAT('https://coryd.dev', g.url) AS url
FROM optimized_genres g FROM optimized_genres g

View file

@ -2,7 +2,6 @@ CREATE OR REPLACE VIEW optimized_syndication AS
WITH syndication_data AS ( WITH syndication_data AS (
SELECT SELECT
p.date AS content_date, p.date AS content_date,
'post' AS content_type,
p.title, p.title,
p.description, p.description,
CONCAT('https://coryd.dev', p.url) AS url, CONCAT('https://coryd.dev', p.url) AS url,
@ -24,7 +23,6 @@ WITH syndication_data AS (
SELECT SELECT
l.date AS content_date, l.date AS content_date,
'link' AS content_type,
l.title, l.title,
l.description, l.description,
l.link AS url, l.link AS url,
@ -52,7 +50,6 @@ WITH syndication_data AS (
SELECT SELECT
b.date_finished AS content_date, b.date_finished AS content_date,
'book' AS content_type,
b.title, b.title,
b.description, b.description,
CONCAT('https://coryd.dev', b.url) AS url, CONCAT('https://coryd.dev', b.url) AS url,
@ -77,7 +74,6 @@ WITH syndication_data AS (
SELECT SELECT
m.last_watched AS content_date, m.last_watched AS content_date,
'movie' AS content_type,
m.title, m.title,
m.description, m.description,
CONCAT('https://coryd.dev', m.url) AS url, CONCAT('https://coryd.dev', m.url) AS url,

View file

@ -1,5 +1,5 @@
CREATE OR REPLACE VIEW optimized_pages AS CREATE OR REPLACE VIEW optimized_pages AS
SELECT SELECT
p.id, p.id,
p.title, p.title,
p.permalink, p.permalink,

View file

@ -13,7 +13,6 @@ SELECT
CONCAT('/', df.filename_disk) AS image, CONCAT('/', df.filename_disk) AS image,
b.favorite, b.favorite,
b.tattoo, b.tattoo,
'book' AS type,
( (
SELECT array_agg(t.name) SELECT array_agg(t.name)

View file

@ -11,7 +11,6 @@ SELECT
m.star_rating AS rating, m.star_rating AS rating,
m.description, m.description,
m.review, m.review,
'movie' AS type,
m.slug AS url, m.slug AS url,
CONCAT('/', df.filename_disk) AS image, CONCAT('/', df.filename_disk) AS image,
CONCAT('/', df2.filename_disk) AS backdrop, CONCAT('/', df2.filename_disk) AS backdrop,

View file

@ -3,7 +3,7 @@ SELECT
ar.name_string AS name, ar.name_string AS name,
ar.slug AS url, ar.slug AS url,
ar.tentative, ar.tentative,
ar.total_plays AS totalPlays, ar.total_plays,
ar.country, ar.country,
ar.description, ar.description,
ar.favorite, ar.favorite,
@ -27,8 +27,8 @@ SELECT
( (
SELECT json_agg(json_build_object( SELECT json_agg(json_build_object(
'name', a.name, 'name', a.name,
'releaseYear', a.release_year, 'release_year', a.release_year,
'totalPlays', a.total_plays, 'total_plays', a.total_plays,
'art', df_album.filename_disk 'art', df_album.filename_disk
) ORDER BY a.release_year) ) ORDER BY a.release_year)
FROM albums a FROM albums a

View file

@ -29,7 +29,6 @@ SELECT
) AS grid, ) AS grid,
json_build_object( json_build_object(
'type', 'tv',
'title', s.title, 'title', s.title,
'year', s.year, 'year', s.year,
'url', s.slug, 'url', s.slug,