diff --git a/migrations/20240125011700_manticore.js b/migrations/20240125011700_manticore.js index 05195b27..39cd51d9 100644 --- a/migrations/20240125011700_manticore.js +++ b/migrations/20240125011700_manticore.js @@ -24,7 +24,9 @@ const scenesFields = ` tag_ids multi, tags text, movie_ids multi, + movies text, serie_ids multi, + series text, meta text, date timestamp, is_showcased bool, diff --git a/src/tools/manticore-scenes.js b/src/tools/manticore-scenes.js index d7a16200..2a953424 100644 --- a/src/tools/manticore-scenes.js +++ b/src/tools/manticore-scenes.js @@ -35,8 +35,8 @@ async function fetchScenes() { grandparents.id as parent_network_id, 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 (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, + COALESCE(JSON_AGG(DISTINCT (movies.id, movies.title)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies, + COALESCE(JSON_AGG(DISTINCT (series.id, series.title)) FILTER (WHERE series.id IS NOT NULL), '[]') as series, studios.showcased IS NOT false 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) @@ -57,7 +57,9 @@ async function fetchScenes() { 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 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 + LEFT JOIN series ON series.id = series_scenes.serie_id GROUP BY releases.id, releases.title, @@ -103,7 +105,9 @@ async function init() { tag_ids multi, tags text, movie_ids multi, + movies text, serie_ids multi, + series text, meta text, date timestamp, is_showcased bool, @@ -114,6 +118,8 @@ async function init() { const scenes = await fetchScenes(); + console.log(scenes.length, scenes.at(0)); + const docs = scenes.map((scene) => { const flatActors = scene.actors.flatMap((actor) => actor.f2.match(/[\w']+/g)); // match word characters to filter out brackets etc. const flatTags = scene.tags.filter((tag) => tag.f3 > 6).flatMap((tag) => (tag.f4 ? `${tag.f2} ${tag.f4}` : tag.f2).match(/[\w']+/g)); // only make top tags searchable to minimize cluttered results @@ -142,8 +148,10 @@ async function init() { actors: scene.actors.map((actor) => actor.f2).join(), tag_ids: scene.tags.map((tag) => tag.f1), tags: flatTags.join(' '), - movie_ids: scene.movies, - serie_ids: scene.series, + movie_ids: scene.movies.map((movie) => movie.f1), + movies: scene.movies.map((movie) => movie.f2).join(' '), + serie_ids: scene.series.map((serie) => serie.f1), + series: scene.series.map((serie) => serie.f2).join(' '), meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined, stashed: scene.stashed || 0, }, diff --git a/src/update-search.js b/src/update-search.js index e26e94f2..50053f59 100644 --- a/src/update-search.js +++ b/src/update-search.js @@ -73,8 +73,8 @@ async function updateManticoreSceneSearch(releaseIds) { grandparents.id as parent_network_id, 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 (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, + COALESCE(JSON_AGG(DISTINCT (movies.id, movies.title)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies, + COALESCE(JSON_AGG(DISTINCT (series.id, series.title)) FILTER (WHERE series.id IS NOT NULL), '[]') as series, studios.showcased IS NOT false 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) @@ -95,7 +95,9 @@ async function updateManticoreSceneSearch(releaseIds) { 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 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 + LEFT JOIN series ON series.id = series_scenes.serie_id ${releaseIds ? 'WHERE releases.id = ANY(?)' : ''} GROUP BY releases.id, @@ -150,7 +152,9 @@ async function updateManticoreSceneSearch(releaseIds) { tag_ids: scene.tags.map((tag) => tag.f1), tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results movie_ids: scene.movies, - serie_ids: scene.series, + movies: scene.movies.map((movie) => movie.f2).join(' '), + serie_ids: scene.series.map((serie) => serie.f1), + series: scene.series.map((serie) => serie.f2).join(' '), meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined, stashed: scene.stashed || 0, },