Excluding BTS scene tags from actor-specific tag filter.
This commit is contained in:
+6
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user