Resolving implied tags on edit.

This commit is contained in:
2026-11-24 02:14:54 +01:00
parent f1891095d2
commit faf775dd48
2 changed files with 40 additions and 2 deletions
+2
View File
@@ -194,10 +194,12 @@ const fields = computed(() => [
'The Bakery Talent',
'Coxxx Models',
'East Coast Talent (ECT)',
'Glow Models',
'Hussie Models',
'Invision Models',
'OC Modeling',
'Spiegler Girls',
'Self Booking',
],
},
{
+38 -2
View File
@@ -1154,6 +1154,40 @@ async function applySceneActorsDelta(sceneId, delta, trx) {
}
}
// add the tags implied by the edited tags (e.g. MFF implies threesome), for the same actor as the implying tag
async function addImpliedTags(tags, trx) {
const implications = await knexOwner('tags')
.select('id', 'implied_tag_ids')
.whereRaw('cardinality(implied_tag_ids) > 0')
.transacting(trx);
const impliedIdsById = Object.fromEntries(implications.map((tag) => [tag.id, tag.implied_tag_ids.filter(Boolean)]));
const tagKey = (tagId, actorId) => `${tagId}:${actorId || null}`;
const tagsByKey = new Map(tags.map((tag) => [tagKey(tag.id, tag.actorId), { ...tag, source: 'editor' }]));
function resolve(tagId, actorId, seen) {
(impliedIdsById[tagId] || []).forEach((impliedId) => {
if (seen.has(impliedId)) {
return;
}
seen.add(impliedId);
const key = tagKey(impliedId, actorId);
if (!tagsByKey.has(key)) {
tagsByKey.set(key, { id: impliedId, actorId, source: 'implied' });
}
resolve(impliedId, actorId, seen);
});
}
tags.forEach((tag) => resolve(tag.id, tag.actorId, new Set([tag.id])));
return Array.from(tagsByKey.values());
}
async function applySceneTagsDelta(sceneId, delta, trx) {
// don't remove unidentified tags
await knexOwner('releases_tags')
@@ -1163,12 +1197,14 @@ async function applySceneTagsDelta(sceneId, delta, trx) {
.transacting(trx);
if (delta.value.length > 0) {
const tags = await addImpliedTags(delta.value, trx);
await knexOwner('releases_tags')
.insert(delta.value.map((tag) => ({
.insert(tags.map((tag) => ({
release_id: sceneId,
tag_id: tag.id,
actor_id: tag.actorId,
source: 'editor',
source: tag.source,
})))
.transacting(trx);
}