forked from DebaucheryLibrarian/traxxx
Added dupe index to manticore scenes and movies tables.
This commit is contained in:
parent
8894a1319e
commit
c5545aae11
|
@ -35,7 +35,8 @@ const scenesFields = `
|
||||||
is_showcased bool,
|
is_showcased bool,
|
||||||
created_at timestamp,
|
created_at timestamp,
|
||||||
effective_date timestamp,
|
effective_date timestamp,
|
||||||
stashed int
|
stashed int,
|
||||||
|
dupe_index int
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const moviesFields = `
|
const moviesFields = `
|
||||||
|
@ -60,7 +61,8 @@ const moviesFields = `
|
||||||
effective_date timestamp,
|
effective_date timestamp,
|
||||||
stashed int,
|
stashed int,
|
||||||
stashed_scenes int,
|
stashed_scenes int,
|
||||||
stashed_total int
|
stashed_total int,
|
||||||
|
dupe_index int
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const actorsFields = `
|
const actorsFields = `
|
||||||
|
|
|
@ -24,6 +24,7 @@ async function fetchScenes() {
|
||||||
releases.title,
|
releases.title,
|
||||||
releases.created_at,
|
releases.created_at,
|
||||||
releases.date,
|
releases.date,
|
||||||
|
releases.entry_id,
|
||||||
releases.shoot_id,
|
releases.shoot_id,
|
||||||
scenes_meta.stashed,
|
scenes_meta.stashed,
|
||||||
entities.id as channel_id,
|
entities.id as channel_id,
|
||||||
|
@ -44,7 +45,8 @@ async function fetchScenes() {
|
||||||
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)
|
||||||
AND (releases_summaries.batch_showcased IS NOT false)
|
AND (releases_summaries.batch_showcased IS NOT false)
|
||||||
AS showcased
|
AS showcased,
|
||||||
|
row_number() OVER (PARTITION BY releases.entry_id, entities.parent_id ORDER BY releases.effective_date DESC) as dupe_index
|
||||||
FROM releases
|
FROM releases
|
||||||
LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id
|
LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id
|
||||||
LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id
|
LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id
|
||||||
|
@ -68,6 +70,7 @@ async function fetchScenes() {
|
||||||
releases.title,
|
releases.title,
|
||||||
releases.created_at,
|
releases.created_at,
|
||||||
releases.date,
|
releases.date,
|
||||||
|
releases.entry_id,
|
||||||
releases.shoot_id,
|
releases.shoot_id,
|
||||||
scenes_meta.stashed,
|
scenes_meta.stashed,
|
||||||
releases_summaries.batch_showcased,
|
releases_summaries.batch_showcased,
|
||||||
|
@ -98,6 +101,7 @@ async function init() {
|
||||||
id int,
|
id int,
|
||||||
title text,
|
title text,
|
||||||
title_filtered text,
|
title_filtered text,
|
||||||
|
entry_id text,
|
||||||
shoot_id text,
|
shoot_id text,
|
||||||
channel_id int,
|
channel_id int,
|
||||||
channel_name text,
|
channel_name text,
|
||||||
|
@ -122,7 +126,8 @@ async function init() {
|
||||||
is_showcased bool,
|
is_showcased bool,
|
||||||
created_at timestamp,
|
created_at timestamp,
|
||||||
effective_date timestamp,
|
effective_date timestamp,
|
||||||
stashed int
|
stashed int,
|
||||||
|
dupe_index int
|
||||||
)`);
|
)`);
|
||||||
|
|
||||||
const scenes = await fetchScenes();
|
const scenes = await fetchScenes();
|
||||||
|
@ -145,6 +150,7 @@ async function init() {
|
||||||
created_at: Math.round(scene.created_at.getTime() / 1000),
|
created_at: Math.round(scene.created_at.getTime() / 1000),
|
||||||
effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000),
|
effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000),
|
||||||
is_showcased: scene.showcased,
|
is_showcased: scene.showcased,
|
||||||
|
entry_id: scene.entry_id || undefined,
|
||||||
shoot_id: scene.shoot_id || undefined,
|
shoot_id: scene.shoot_id || undefined,
|
||||||
channel_id: scene.channel_id,
|
channel_id: scene.channel_id,
|
||||||
channel_slug: scene.channel_slug,
|
channel_slug: scene.channel_slug,
|
||||||
|
@ -166,6 +172,7 @@ async function init() {
|
||||||
series: scene.series.map((serie) => serie.f2).join(' '),
|
series: scene.series.map((serie) => serie.f2).join(' '),
|
||||||
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,
|
||||||
|
dupe_index: scene.dupe_index || 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,8 @@ async function updateManticoreSceneSearch(releaseIds) {
|
||||||
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)
|
||||||
AND (releases_summaries.batch_showcased IS NOT false)
|
AND (releases_summaries.batch_showcased IS NOT false)
|
||||||
AS showcased
|
AS showcased,
|
||||||
|
row_number() OVER (PARTITION BY releases.entry_id, parents.id ORDER BY releases.effective_date DESC) as dupe_index
|
||||||
FROM releases
|
FROM releases
|
||||||
LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id
|
LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id
|
||||||
LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id
|
LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id
|
||||||
|
@ -166,6 +167,7 @@ async function updateManticoreSceneSearch(releaseIds) {
|
||||||
series: scene.series.map((serie) => serie.f2).join(' '),
|
series: scene.series.map((serie) => serie.f2).join(' '),
|
||||||
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,
|
||||||
|
dupe_index: scene.dupe_index || 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -249,7 +251,8 @@ async function updateManticoreMovieSearch(movieIds) {
|
||||||
movies_covers IS NOT NULL as has_cover,
|
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 (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 (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
|
FROM movies
|
||||||
LEFT JOIN movies_meta ON movies_meta.movie_id = movies.id
|
LEFT JOIN movies_meta ON movies_meta.movie_id = movies.id
|
||||||
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
||||||
|
@ -324,6 +327,7 @@ async function updateManticoreMovieSearch(movieIds) {
|
||||||
stashed: movie.stashed || 0,
|
stashed: movie.stashed || 0,
|
||||||
stashed_scenes: movie.stashed_scenes || 0,
|
stashed_scenes: movie.stashed_scenes || 0,
|
||||||
stashed_total: movie.stashed_total || 0,
|
stashed_total: movie.stashed_total || 0,
|
||||||
|
dupe_index: movie.dupe_index || 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue