From b6a402d96478b1617295ee515610cf0756e28d7c Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 4 Jun 2024 03:49:35 +0200 Subject: [PATCH] Added grandparent network IDs to manticore scene database. --- src/tools/manticore-scenes.js | 5 ++++- src/update-search.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tools/manticore-scenes.js b/src/tools/manticore-scenes.js index 4f2ab36a..e9e57f98 100644 --- a/src/tools/manticore-scenes.js +++ b/src/tools/manticore-scenes.js @@ -31,6 +31,7 @@ async function fetchScenes() { parents.id as network_id, parents.slug as network_slug, parents.name as network_name, + 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, @@ -43,6 +44,7 @@ async function fetchScenes() { LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id LEFT JOIN entities ON releases.entity_id = entities.id LEFT JOIN entities AS parents ON parents.id = entities.parent_id + LEFT JOIN entities AS grandparents ON grandparents.id = parents.parent_id LEFT JOIN entities AS studios ON studios.id = releases.studio_id LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = releases.id LEFT JOIN releases_directors AS local_directors ON local_directors.release_id = releases.id @@ -68,6 +70,7 @@ async function fetchScenes() { parents.name, parents.slug, parents.alias, + grandparents.id, entities.showcased, parents.showcased, studios.showcased; @@ -130,7 +133,7 @@ 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].filter(Boolean), // manticore does not support OR, this allows IN + entity_ids: [scene.channel_id, scene.network_id, scene.parent_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), diff --git a/src/update-search.js b/src/update-search.js index 7d6eb2cc..880a30f3 100644 --- a/src/update-search.js +++ b/src/update-search.js @@ -69,6 +69,7 @@ async function updateManticoreSceneSearch(releaseIds) { parents.id as network_id, parents.slug as network_slug, parents.name as network_name, + 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, @@ -81,6 +82,7 @@ async function updateManticoreSceneSearch(releaseIds) { LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id LEFT JOIN entities ON releases.entity_id = entities.id LEFT JOIN entities AS parents ON parents.id = entities.parent_id + LEFT JOIN entities AS grandparents ON grandparents.id = parents.parent_id LEFT JOIN entities AS studios ON studios.id = releases.studio_id LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = releases.id LEFT JOIN releases_directors AS local_directors ON local_directors.release_id = releases.id @@ -108,6 +110,7 @@ async function updateManticoreSceneSearch(releaseIds) { parents.name, parents.slug, parents.alias, + grandparents.id, parents.showcased, studios.showcased `, releaseIds && [releaseIds]); @@ -137,7 +140,7 @@ 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].filter(Boolean), // manticore does not support OR, this allows IN + entity_ids: [scene.channel_id, scene.network_id, scene.parent_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),