Resolving implied tags on edit.
This commit is contained in:
@@ -194,10 +194,12 @@ const fields = computed(() => [
|
|||||||
'The Bakery Talent',
|
'The Bakery Talent',
|
||||||
'Coxxx Models',
|
'Coxxx Models',
|
||||||
'East Coast Talent (ECT)',
|
'East Coast Talent (ECT)',
|
||||||
|
'Glow Models',
|
||||||
'Hussie Models',
|
'Hussie Models',
|
||||||
'Invision Models',
|
'Invision Models',
|
||||||
'OC Modeling',
|
'OC Modeling',
|
||||||
'Spiegler Girls',
|
'Spiegler Girls',
|
||||||
|
'Self Booking',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+38
-2
@@ -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) {
|
async function applySceneTagsDelta(sceneId, delta, trx) {
|
||||||
// don't remove unidentified tags
|
// don't remove unidentified tags
|
||||||
await knexOwner('releases_tags')
|
await knexOwner('releases_tags')
|
||||||
@@ -1163,12 +1197,14 @@ async function applySceneTagsDelta(sceneId, delta, trx) {
|
|||||||
.transacting(trx);
|
.transacting(trx);
|
||||||
|
|
||||||
if (delta.value.length > 0) {
|
if (delta.value.length > 0) {
|
||||||
|
const tags = await addImpliedTags(delta.value, trx);
|
||||||
|
|
||||||
await knexOwner('releases_tags')
|
await knexOwner('releases_tags')
|
||||||
.insert(delta.value.map((tag) => ({
|
.insert(tags.map((tag) => ({
|
||||||
release_id: sceneId,
|
release_id: sceneId,
|
||||||
tag_id: tag.id,
|
tag_id: tag.id,
|
||||||
actor_id: tag.actorId,
|
actor_id: tag.actorId,
|
||||||
source: 'editor',
|
source: tag.source,
|
||||||
})))
|
})))
|
||||||
.transacting(trx);
|
.transacting(trx);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user