Storing serie IDs to manticore scenes table.

This commit is contained in:
DebaucheryLibrarian 2024-06-02 00:28:42 +02:00
parent 8b0b340031
commit 43752cef92
3 changed files with 11 additions and 4 deletions

View File

@ -23,6 +23,8 @@ const scenesFields = `
actors text, actors text,
tag_ids multi, tag_ids multi,
tags text, tags text,
movie_ids multi,
serie_ids multi,
meta text, meta text,
date timestamp, date timestamp,
is_showcased bool, is_showcased bool,

View File

@ -33,7 +33,8 @@ async function fetchScenes() {
parents.name as network_name, parents.name as network_name,
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors, COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
COALESCE(JSON_AGG(DISTINCT (movies.id)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies, COALESCE(JSON_AGG(DISTINCT (movies_scenes.movie_id)) FILTER (WHERE movies_scenes.movie_id IS NOT NULL), '[]') as movies,
COALESCE(JSON_AGG(DISTINCT (series_scenes.serie_id)) FILTER (WHERE series_scenes.serie_id IS NOT NULL), '[]') as series,
studios.showcased IS NOT false studios.showcased IS NOT false
AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true) AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true)
AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true) AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true)
@ -51,7 +52,7 @@ async function fetchScenes() {
LEFT JOIN tags ON local_tags.tag_id = tags.id LEFT JOIN tags ON local_tags.tag_id = tags.id
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id
LEFT JOIN movies ON movies.id = movies_scenes.movie_id LEFT JOIN series_scenes ON series_scenes.scene_id = releases.id
GROUP BY GROUP BY
releases.id, releases.id,
releases.title, releases.title,
@ -95,6 +96,7 @@ async function init() {
tag_ids multi, tag_ids multi,
tags text, tags text,
movie_ids multi, movie_ids multi,
serie_ids multi,
meta text, meta text,
date timestamp, date timestamp,
is_showcased bool, is_showcased bool,
@ -134,6 +136,7 @@ async function init() {
tag_ids: scene.tags.map((tag) => tag.f1), tag_ids: scene.tags.map((tag) => tag.f1),
tags: flatTags.join(' '), tags: flatTags.join(' '),
movie_ids: scene.movies, movie_ids: scene.movies,
serie_ids: scene.series,
meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined, meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined,
stashed: scene.stashed || 0, stashed: scene.stashed || 0,
}, },

View File

@ -71,7 +71,8 @@ async function updateManticoreSceneSearch(releaseIds) {
parents.name as network_name, parents.name as network_name,
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors, COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
COALESCE(JSON_AGG(DISTINCT (movies.id)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies, COALESCE(JSON_AGG(DISTINCT (movies_scenes.movie_id)) FILTER (WHERE movies_scenes.movie_id IS NOT NULL), '[]') as movies,
COALESCE(JSON_AGG(DISTINCT (series_scenes.serie_id)) FILTER (WHERE series_scenes.serie_id IS NOT NULL), '[]') as series,
studios.showcased IS NOT false studios.showcased IS NOT false
AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true) AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true)
AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true) AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true)
@ -89,7 +90,7 @@ async function updateManticoreSceneSearch(releaseIds) {
LEFT JOIN tags ON local_tags.tag_id = tags.id LEFT JOIN tags ON local_tags.tag_id = tags.id
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id
LEFT JOIN movies ON movies.id = movies_scenes.movie_id LEFT JOIN series_scenes ON series_scenes.scene_id = releases.id
${releaseIds ? 'WHERE releases.id = ANY(?)' : ''} ${releaseIds ? 'WHERE releases.id = ANY(?)' : ''}
GROUP BY GROUP BY
releases.id, releases.id,
@ -142,6 +143,7 @@ async function updateManticoreSceneSearch(releaseIds) {
tag_ids: scene.tags.map((tag) => tag.f1), tag_ids: scene.tags.map((tag) => tag.f1),
tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results
movie_ids: scene.movies, movie_ids: scene.movies,
serie_ids: scene.series,
meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined, meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined,
stashed: scene.stashed || 0, stashed: scene.stashed || 0,
}, },