diff --git a/migrations/20240125011700_manticore.js b/migrations/20240125011700_manticore.js index 43ea6b0df..03bd067c9 100644 --- a/migrations/20240125011700_manticore.js +++ b/migrations/20240125011700_manticore.js @@ -41,6 +41,7 @@ const moviesFields = ` network_id int, network_name text, network_slug text, + entity_ids multi, actor_ids multi, actors text, tag_ids multi, diff --git a/src/tools/manticore-movies.js b/src/tools/manticore-movies.js index 9d875ddbf..18d8529ad 100644 --- a/src/tools/manticore-movies.js +++ b/src/tools/manticore-movies.js @@ -83,6 +83,7 @@ async function init() { network_id int, network_name text, network_slug text, + entity_ids multi, actor_ids multi, actors text, tag_ids multi, @@ -120,6 +121,7 @@ async function init() { network_id: movie.network_id || undefined, network_slug: movie.network_slug || undefined, network_name: movie.network_name || undefined, + entity_ids: [movie.channel_id, movie.network_id].filter(Boolean), // manticore does not support OR, this allows IN actor_ids: movie.actors.map((actor) => actor.f1), actors: movie.actors.map((actor) => actor.f2).join(), tag_ids: movie.tags.map((tag) => tag.f1), diff --git a/src/tools/manticore-scenes.js b/src/tools/manticore-scenes.js index b4a6e17f1..cc7cf95c6 100644 --- a/src/tools/manticore-scenes.js +++ b/src/tools/manticore-scenes.js @@ -32,7 +32,8 @@ async function fetchScenes() { parents.slug as network_slug, 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 (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 FROM releases LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id LEFT JOIN entities ON releases.entity_id = entities.id @@ -44,6 +45,8 @@ async function fetchScenes() { LEFT JOIN actors AS directors ON local_directors.director_id = directors.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 movies_scenes ON movies_scenes.scene_id = releases.id + LEFT JOIN movies ON movies.id = movies_scenes.movie_id GROUP BY releases.id, releases.title, @@ -83,6 +86,7 @@ async function init() { actors text, tag_ids multi, tags text, + movie_ids multi, meta text, date timestamp, is_showcased bool, @@ -115,11 +119,12 @@ async function init() { network_id: scene.network_id || undefined, network_slug: scene.network_slug || undefined, network_name: scene.network_name || undefined, - entity_ids: [scene.channel_id, scene.network_id], // manticore does not support OR, this allows IN + entity_ids: [scene.channel_id, scene.network_id].filter(Boolean), // manticore does not support OR, this allows IN actor_ids: scene.actors.map((actor) => actor.f1), actors: scene.actors.map((actor) => actor.f2).join(), tag_ids: scene.tags.map((tag) => tag.f1), tags: flatTags.join(' '), + movie_ids: scene.movies, 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 fe287435b..8d7d2cf9b 100644 --- a/src/update-search.js +++ b/src/update-search.js @@ -71,6 +71,7 @@ async function updateManticoreSceneSearch(releaseIds) { 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 (tags.id, tags.name, tags.priority)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, + COALESCE(JSON_AGG(DISTINCT (movies.id)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies, 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) @@ -87,6 +88,8 @@ async function updateManticoreSceneSearch(releaseIds) { LEFT JOIN actors AS directors ON local_directors.director_id = directors.id LEFT JOIN tags ON local_tags.tag_id = tags.id AND tags.priority >= 6 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 ${releaseIds ? 'WHERE releases.id = ANY(?)' : ''} GROUP BY releases.id, @@ -133,11 +136,12 @@ async function updateManticoreSceneSearch(releaseIds) { network_id: scene.network_id || undefined, network_slug: scene.network_slug || undefined, network_name: scene.network_name || undefined, - entity_ids: [scene.channel_id, scene.network_id], // manticore does not support OR, this allows IN + entity_ids: [scene.channel_id, scene.network_id].filter(Boolean), // manticore does not support OR, this allows IN actor_ids: scene.actors.map((actor) => actor.f1), actors: scene.actors.map((actor) => actor.f2).join(), tag_ids: scene.tags.map((tag) => tag.f1), tags: scene.tags.filter((tag) => tag.f3 > 6).map((tag) => tag.f2).join(), // only make top tags searchable to minimize cluttered results + movie_ids: scene.movies, meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined, stashed: scene.stashed || 0, }, @@ -277,6 +281,7 @@ async function updateManticoreMovieSearch(movieIds) { network_id: movie.network_id || undefined, network_slug: movie.network_slug || undefined, network_name: movie.network_name || undefined, + entity_ids: [movie.channel_id, movie.network_id].filter(Boolean), // manticore does not support OR, this allows IN actor_ids: movie.actors.map((actor) => actor.f1), actors: movie.actors.map((actor) => actor.f2).join(), tag_ids: movie.tags.map((tag) => tag.f1),