Excluding BTS scene tags from actor-specific tag filter.
This commit is contained in:
@@ -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