From 15896d4c5b9ea9cdc0d3e92a90a651803ed5b221 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 5 Nov 2024 04:07:09 +0100 Subject: [PATCH] Added dupe index to manticore movies table. --- src/tools/manticore-movies.js | 7 +++++-- src/tools/manticore-scenes.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/manticore-movies.js b/src/tools/manticore-movies.js index 1b12e8c2..a6051e68 100644 --- a/src/tools/manticore-movies.js +++ b/src/tools/manticore-movies.js @@ -35,7 +35,8 @@ async function fetchMovies() { movies_covers IS NOT NULL as has_cover, 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 (movie_tags.id, movie_tags.name, movie_tags.priority, movie_tags_aliases.name)) FILTER (WHERE movie_tags.id IS NOT NULL), '[]') as movie_tags + COALESCE(JSON_AGG(DISTINCT (movie_tags.id, movie_tags.name, movie_tags.priority, movie_tags_aliases.name)) FILTER (WHERE movie_tags.id IS NOT NULL), '[]') as movie_tags, + row_number() OVER (PARTITION BY movies.entry_id, parents.id ORDER BY movies.effective_date DESC) as dupe_index FROM movies LEFT JOIN movies_meta ON movies_meta.movie_id = movies.id LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id @@ -99,7 +100,8 @@ async function init() { effective_date timestamp, stashed int, stashed_scenes int, - stashed_total int + stashed_total int, + dupe_index int )`); const movies = await fetchMovies(); @@ -142,6 +144,7 @@ async function init() { stashed: movie.stashed || 0, stashed_scenes: movie.stashed_scenes || 0, stashed_total: movie.stashed_total || 0, + dupe_index: movie.dupe_index || 0, }, }, }; diff --git a/src/tools/manticore-scenes.js b/src/tools/manticore-scenes.js index f66726cc..3e27edab 100644 --- a/src/tools/manticore-scenes.js +++ b/src/tools/manticore-scenes.js @@ -46,7 +46,7 @@ async function fetchScenes() { AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true) AND (releases_summaries.batch_showcased IS NOT false) AS showcased, - row_number() OVER (PARTITION BY releases.entry_id, entities.parent_id ORDER BY releases.effective_date DESC) as dupe_index + row_number() OVER (PARTITION BY releases.entry_id, parents.id ORDER BY releases.effective_date DESC) as dupe_index FROM releases LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id