feat: everything is related
This commit is contained in:
parent
d1e3ab23bb
commit
077c54d5fb
20 changed files with 325 additions and 274 deletions
|
@ -1,4 +1,5 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
import slugify from 'slugify'
|
||||
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
|
||||
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL
|
||||
|
@ -26,9 +27,12 @@ const fetchAllBooks = async () => {
|
|||
review,
|
||||
art,
|
||||
favorite,
|
||||
tattoo,
|
||||
tags,
|
||||
artists,
|
||||
movies
|
||||
movies,
|
||||
genres,
|
||||
shows
|
||||
`)
|
||||
.order('date_finished', { ascending: false })
|
||||
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
|
||||
|
@ -57,6 +61,7 @@ const processBooks = (books) => {
|
|||
review: book['review'],
|
||||
rating: book['star_rating'] !== 'unrated' ? book['star_rating'] : '',
|
||||
favorite: book['favorite'],
|
||||
tattoo: book['tattoo'],
|
||||
description: book['description'],
|
||||
image: `/${book['art']}`,
|
||||
url: `/books/${book['isbn']}`,
|
||||
|
@ -74,6 +79,14 @@ const processBooks = (books) => {
|
|||
movie['url'] =`/watching/movies/${movie['tmdb_id']}`
|
||||
return movie
|
||||
}).sort((a, b) => b['year'] - a['year']) : null,
|
||||
genres: book['genres']?.[0]?.['id'] ? book['genres'].map(genre => {
|
||||
genre['url'] = `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}`
|
||||
return genre
|
||||
}).sort((a, b) => a['name'].localeCompare(b['name'])) : null,
|
||||
shows: book['shows']?.[0]?.['id'] ? book['shows'].map(show => {
|
||||
show['url'] = `/watching/shows/${show['tmdb_id']}`
|
||||
return show
|
||||
}).sort((a, b) => b['year'] - a['year']) : null,
|
||||
year,
|
||||
}
|
||||
})
|
||||
|
|
|
@ -8,7 +8,7 @@ const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
|||
|
||||
const fetchGenresWithArtists = async () => {
|
||||
const { data, error } = await supabase
|
||||
.from('genres')
|
||||
.from('optimized_genres')
|
||||
.select(`
|
||||
name,
|
||||
description,
|
||||
|
@ -21,7 +21,9 @@ const fetchGenresWithArtists = async () => {
|
|||
country,
|
||||
description,
|
||||
favorite
|
||||
)
|
||||
),
|
||||
books,
|
||||
movies
|
||||
`)
|
||||
.order('id', { ascending: true })
|
||||
|
||||
|
@ -36,7 +38,20 @@ const fetchGenresWithArtists = async () => {
|
|||
...artist,
|
||||
country: parseCountryField(artist['country'])
|
||||
})),
|
||||
url: `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}`
|
||||
url: `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}`,
|
||||
books: genre['books']?.[0]?.['id'] ? genre['books'].map(book => ({
|
||||
title: book['title'],
|
||||
author: book['author'],
|
||||
isbn: book['isbn'],
|
||||
description: book['description'],
|
||||
url: `/books/${book['isbn']}`,
|
||||
})).sort((a, b) => a['title'].localeCompare(b['title'])) : null,
|
||||
movies: genre['movies']?.[0]?.['id'] ? genre['movies'].map(movie => ({
|
||||
title: movie['title'],
|
||||
year: movie['year'],
|
||||
tmdb_id: movie['tmdb_id'],
|
||||
url: `/watching/movies/${movie['tmdb_id']}`,
|
||||
})).sort((a, b) => b['year'] - a['year']) : null,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
import { DateTime } from 'luxon'
|
||||
import slugify from 'slugify'
|
||||
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
|
||||
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL
|
||||
|
@ -23,6 +24,7 @@ const fetchAllMovies = async () => {
|
|||
collected,
|
||||
plays,
|
||||
favorite,
|
||||
tattoo,
|
||||
star_rating,
|
||||
description,
|
||||
review,
|
||||
|
@ -30,7 +32,9 @@ const fetchAllMovies = async () => {
|
|||
backdrop,
|
||||
tags,
|
||||
artists,
|
||||
books
|
||||
books,
|
||||
genres,
|
||||
shows
|
||||
`)
|
||||
.order('last_watched', { ascending: false })
|
||||
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
|
||||
|
@ -75,6 +79,14 @@ const processMovies = (movies) => {
|
|||
book['url'] = `/books/${book['isbn']}`
|
||||
return book
|
||||
}).sort((a, b) => a['title'].localeCompare(b['title'])) : null,
|
||||
genres: item['genres']?.[0]?.['id'] ? item['genres'].map(genre => {
|
||||
genre['url'] = `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}`
|
||||
return genre
|
||||
}).sort((a, b) => a['title'].localeCompare(b['title'])) : null,
|
||||
shows: item['shows']?.[0]?.['id'] ? item['shows'].map(show => {
|
||||
show['url'] = `/watching/shows/${show['tmdb_id']}`
|
||||
return show
|
||||
}).sort((a, b) => b['year'] - a['year']) : null,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,14 @@ const fetchAllShows = async () => {
|
|||
year,
|
||||
collected,
|
||||
favorite,
|
||||
tattoo,
|
||||
description,
|
||||
review,
|
||||
art,
|
||||
backdrop,
|
||||
episodes
|
||||
episodes,
|
||||
movies,
|
||||
books
|
||||
`)
|
||||
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
|
||||
|
||||
|
@ -46,7 +49,19 @@ const prepareShowData = (show) => ({
|
|||
image: show['art'] ? `/${show['art']}` : '',
|
||||
backdrop: show['backdrop'] ? `/${show['backdrop']}` : '',
|
||||
url: `/watching/shows/${show['tmdb_id']}`,
|
||||
episodes: show['episodes'] || []
|
||||
episodes: show['episodes'] || [],
|
||||
tattoo: show['tattoo'],
|
||||
movies: show['movies']?.[0]?.['id'] ? show['movies'].map(movie => {
|
||||
movie['url'] = `/watching/movies/${movie['tmdb_id']}`
|
||||
return movie
|
||||
}).sort((a, b) => b['year'] - a['year']) : null,
|
||||
books: show['books']?.[0]?.['id'] ? show['books'].map(book => ({
|
||||
title: book['title'],
|
||||
author: book['author'],
|
||||
isbn: book['isbn'],
|
||||
description: book['description'],
|
||||
url: `/books/${book['isbn']}`,
|
||||
})).sort((a, b) => a['title'].localeCompare(b['title'])) : null,
|
||||
})
|
||||
|
||||
const prepareEpisodeData = (show) => show['episodes'].map(episode => ({
|
||||
|
|
Reference in a new issue