chore: search cleanup
This commit is contained in:
parent
71eaab3a36
commit
6833d054cc
4 changed files with 25 additions and 24 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "1.5.8",
|
"version": "1.5.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "1.5.8",
|
"version": "1.5.9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cdransf/api-text": "^1.5.0",
|
"@cdransf/api-text": "^1.5.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "1.5.8",
|
"version": "1.5.9",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -107,9 +107,10 @@ window.addEventListener("load", () => {
|
||||||
"total_plays",
|
"total_plays",
|
||||||
],
|
],
|
||||||
searchOptions: {
|
searchOptions: {
|
||||||
boost: { title: 2, tags: 1.5 },
|
|
||||||
prefix: true,
|
prefix: true,
|
||||||
fuzzy: 0.3,
|
fuzzy: 0.2,
|
||||||
|
boost: { title: 2, tags: 1.5 },
|
||||||
|
sort: (a, b) => b.score - a.score,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const $form = document.querySelector(".search__form");
|
const $form = document.querySelector(".search__form");
|
||||||
|
|
|
@ -8,7 +8,8 @@ WITH search_data AS (
|
||||||
p.tags,
|
p.tags,
|
||||||
NULL AS genre_name,
|
NULL AS genre_name,
|
||||||
NULL AS genre_url,
|
NULL AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
p.date AS content_date
|
||||||
FROM optimized_posts p
|
FROM optimized_posts p
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -21,7 +22,8 @@ WITH search_data AS (
|
||||||
l.tags,
|
l.tags,
|
||||||
NULL AS genre_name,
|
NULL AS genre_name,
|
||||||
NULL AS genre_url,
|
NULL AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
l.date AS content_date
|
||||||
FROM optimized_links l
|
FROM optimized_links l
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -37,7 +39,8 @@ WITH search_data AS (
|
||||||
b.tags,
|
b.tags,
|
||||||
NULL AS genre_name,
|
NULL AS genre_name,
|
||||||
NULL AS genre_url,
|
NULL AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
b.date_finished AS content_date
|
||||||
FROM optimized_books b
|
FROM optimized_books b
|
||||||
WHERE LOWER(b.status) = 'finished'
|
WHERE LOWER(b.status) = 'finished'
|
||||||
|
|
||||||
|
@ -54,7 +57,8 @@ WITH search_data AS (
|
||||||
m.tags,
|
m.tags,
|
||||||
NULL AS genre_name,
|
NULL AS genre_name,
|
||||||
NULL AS genre_url,
|
NULL AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
m.last_watched AS content_date
|
||||||
FROM optimized_movies m
|
FROM optimized_movies m
|
||||||
WHERE m.last_watched IS NOT NULL
|
WHERE m.last_watched IS NOT NULL
|
||||||
|
|
||||||
|
@ -68,7 +72,8 @@ WITH search_data AS (
|
||||||
ARRAY[ar.genre_name] AS tags,
|
ARRAY[ar.genre_name] AS tags,
|
||||||
ar.genre_name,
|
ar.genre_name,
|
||||||
CONCAT('https://coryd.dev', ar.genre_slug) AS genre_url,
|
CONCAT('https://coryd.dev', ar.genre_slug) AS genre_url,
|
||||||
ar.total_plays
|
ar.total_plays,
|
||||||
|
NULL AS content_date
|
||||||
FROM optimized_artists ar
|
FROM optimized_artists ar
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -81,7 +86,8 @@ WITH search_data AS (
|
||||||
NULL AS tags,
|
NULL AS tags,
|
||||||
g.name AS genre_name,
|
g.name AS genre_name,
|
||||||
CONCAT('https://coryd.dev', g.url) AS genre_url,
|
CONCAT('https://coryd.dev', g.url) AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
NULL AS content_date
|
||||||
FROM optimized_genres g
|
FROM optimized_genres g
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -97,24 +103,18 @@ WITH search_data AS (
|
||||||
s.tags,
|
s.tags,
|
||||||
NULL AS genre_name,
|
NULL AS genre_name,
|
||||||
NULL AS genre_url,
|
NULL AS genre_url,
|
||||||
NULL::integer AS total_plays
|
NULL::integer AS total_plays,
|
||||||
|
s.last_watched_at AS content_date
|
||||||
FROM optimized_shows s
|
FROM optimized_shows s
|
||||||
WHERE s.last_watched_at IS NOT NULL
|
WHERE s.last_watched_at IS NOT NULL
|
||||||
),
|
),
|
||||||
search_data_with_id AS (
|
search_data_with_id AS (
|
||||||
SELECT
|
SELECT
|
||||||
ROW_NUMBER() OVER (ORDER BY url) AS id,
|
ROW_NUMBER() OVER (ORDER BY content_date DESC NULLS LAST, url) AS id,
|
||||||
search_data.*
|
search_data.*
|
||||||
FROM search_data
|
FROM search_data
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id, url, title, description, tags, genre_name, genre_url, type, total_plays
|
||||||
url,
|
FROM search_data_with_id
|
||||||
title,
|
ORDER BY content_date DESC NULLS LAST, url;
|
||||||
description,
|
|
||||||
tags,
|
|
||||||
genre_name,
|
|
||||||
genre_url,
|
|
||||||
type,
|
|
||||||
total_plays
|
|
||||||
FROM search_data_with_id;
|
|
Reference in a new issue