From 54afdb156abefc4921354f6819e81db6db5a5249 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 23 Nov 2026 00:41:33 +0100 Subject: [PATCH] Excluding BTS scene tags from actor-specific tag filter. --- src/sync.js | 10 ++++++---- tools/import-revisions.js | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/sync.js b/src/sync.js index 89f7cea..7424027 100644 --- a/src/sync.js +++ b/src/sync.js @@ -122,7 +122,7 @@ export async function syncManticoreScenes(sceneIds) { COUNT(DISTINCT local_actors.id) FILTER (WHERE COALESCE(actors.gender, local_actors.gender) = 'male') as male_count, COUNT(DISTINCT local_actors.id) FILTER (WHERE COALESCE(actors.gender, local_actors.gender) = 'transsexual') as trans_count, COUNT(DISTINCT local_actors.id) FILTER (WHERE local_actors.actor_id IS NULL) as unidentified_count, - COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name, local_tags.actor_id)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, + COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name, local_tags.actor_id, tags.slug)) 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, studios.showcased IS NOT false @@ -195,7 +195,9 @@ 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]); - const isCompilation = scene.tags.some((tag) => tag.f2 === 'compilation'); + // tag slugs, f6 = tag slug + const nonSceneTags = ['compilation', 'bts']; + const isNonScene = scene.tags.some((tag) => nonSceneTags.includes(tag.f6)); // use decimal packing with 5-decimal pad to allow for actor-specific tags, i.e. actor 135 tag 5 = 13500005 // all global tags are necessarily < 10,000, all tags for actor 135 are >= 13500000 and <= 13599999 @@ -206,8 +208,8 @@ export async function syncManticoreScenes(sceneIds) { return tag.f5 * 1_000_00 + tag.f1; } - if (isCompilation && tag.f2 !== 'compilation') { - // tag is part of a compilation, pack with arbitrary large number that will never be an actor ID (famous last words) + if (isNonScene && !nonSceneTags.includes(tag.f6)) { + // tag is part of a compilation or BTS, pack with arbitrary large number that will never be an actor ID (famous last words) return 900_000_000 * 1_000_00 + tag.f1; } diff --git a/tools/import-revisions.js b/tools/import-revisions.js index a056443..0c100cb 100644 --- a/tools/import-revisions.js +++ b/tools/import-revisions.js @@ -3,7 +3,7 @@ import process from 'node:process'; import yargs from 'yargs'; import { knexOwner as knex } from '../src/knex.js'; -import { createSceneRevision, fetchRevisionRelations, reviewSceneRevision } from '../src/scenes.js'; +import { createSceneRevision, fetchRelationTypes, fetchRevisionRelations, reviewSceneRevision } from '../src/scenes.js'; import { syncScenes } from '../src/sync.js'; import { fetchUser } from '../src/users.js'; import runTool from './run-tool.js'; @@ -116,12 +116,25 @@ async function skipMissing(entries) { return curatedEntries; } +let symmetricTypes = null; + +// symmetric types are stored with direction 'both', whatever direction the file gives +async function getRelationKey(relation) { + symmetricTypes ??= new Set((await fetchRelationTypes()).filter((type) => type.symmetric).map((type) => type.type)); + + return `${symmetricTypes.has(relation.type) ? 'both' : relation.direction}:${relation.type}:${relation.sceneId}`; +} + async function curateEdits(entry) { if (!entry.addRelations) { return entry.edits; } const currentRelations = await fetchRevisionRelations(entry.sceneId); + const currentKeys = new Set(await Promise.all(currentRelations.map((relation) => getRelationKey(relation)))); + + // relations that already exist are left as they are, so the file can't clear or overwrite their comments + const addRelations = (await Promise.all(entry.addRelations.map(async (relation) => (currentKeys.has(await getRelationKey(relation)) ? null : relation)))).filter(Boolean); return { ...entry.edits, @@ -132,7 +145,7 @@ async function curateEdits(entry) { direction: relation.direction, comment: relation.comment, })), - ...entry.addRelations, + ...addRelations, ], }; }