From 4b39f787c977e21358f3b669af5268d8e34d8390 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 29 Jun 2026 00:37:18 +0200 Subject: [PATCH] Including scene actor aliases in manticore. --- src/app.js | 2 ++ src/sync.js | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app.js b/src/app.js index 45661f8..ba9b6a5 100644 --- a/src/app.js +++ b/src/app.js @@ -1,10 +1,12 @@ import initServer from './web/server.js'; import { initCaches } from './cache.js'; +import { initSyncCron } from './sync.js'; async function init() { await initCaches(); initServer(); + initSyncCron(); } init(); diff --git a/src/sync.js b/src/sync.js index a0556c9..a4c7398 100644 --- a/src/sync.js +++ b/src/sync.js @@ -114,6 +114,7 @@ export async function syncManticoreScenes(sceneIds) { studios.name as studio_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 (actors_aliases.id, actors_aliases.name)) FILTER (WHERE actors_aliases.id IS NOT NULL), '[]') as actors_aliases, 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, 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, @@ -135,6 +136,7 @@ export async function syncManticoreScenes(sceneIds) { LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = releases.id LEFT JOIN actors ON local_actors.actor_id = actors.id LEFT JOIN actors AS directors ON local_directors.director_id = directors.id + LEFT JOIN actors AS actors_aliases ON actors_aliases.id = local_actors.alias_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 @@ -185,6 +187,8 @@ export async function syncManticoreScenes(sceneIds) { const flatTags = scene.tags.filter((tag) => tag.f3 > 6).flatMap((tag) => [tag.f2].concat(tag.f4)).filter(Boolean); // only make top tags searchable to minimize cluttered results const filteredTitle = filterTitle(scene.title, [...flatActors, ...flatTags]); + // TODO: reconsider how direct vs indirect tags are stored and searched + return { replace: { index: 'scenes', @@ -207,8 +211,8 @@ export async function syncManticoreScenes(sceneIds) { studio_slug: scene.studio_slug || undefined, studio_name: scene.studio_name || undefined, entity_ids: [scene.channel_id, scene.network_id, scene.parent_network_id, scene.studio_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(), + actor_ids: scene.actors.map((actor) => actor.f1), // don't include aliases in ID or they would show up in filters + actors: Array.from(new Set([...scene.actors.map((actor) => actor.f2), ...scene.actors_aliases.map((actor) => actor.f2)])).join(), tag_ids: scene.tags.map((tag) => tag.f1), tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results movie_ids: scene.movies.map((movie) => movie.f1), @@ -470,11 +474,13 @@ export async function syncQueue() { logger[process.tasks > 0 ? 'info' : 'verbose'](`Processed ${tasks.length} sync items`); } -CronJob.from({ - cronTime: config.sync.crontab, - async onTick() { - syncQueue(); - }, - start: config.sync.enabled, - runOnInit: true, -}); +export function initSyncCron() { + CronJob.from({ + cronTime: config.sync.crontab, + async onTick() { + syncQueue(); + }, + start: config.sync.enabled, + runOnInit: true, + }); +}