Compare commits
38 Commits
bad116cdc0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f8d3b1ad2 | |||
| a91350bcab | |||
| b00425e9c0 | |||
| c82a3477bd | |||
| 040dca3829 | |||
| 8674c1d361 | |||
| 6c9cb4201a | |||
| 7c32a5e824 | |||
| 6c2f9cb62e | |||
| 3cece877f7 | |||
| 8dd700f62e | |||
| 804cdcbf59 | |||
| 885fe7c9e9 | |||
| 930cc52373 | |||
| 4636a213b3 | |||
| 469954f613 | |||
| 5bdcd65d42 | |||
| cb91cd4cc7 | |||
| e04ddaed9b | |||
| 605da5e46c | |||
| 360e8ece85 | |||
| 1543bf9d03 | |||
| 287932d9d7 | |||
| 7c4de31c12 | |||
| 497c6150f7 | |||
| 514f51f111 | |||
| 244dc4fff6 | |||
| 4b39f787c9 | |||
| fb92b9c973 | |||
| 181358db7d | |||
| 3790567d44 | |||
| b3af993236 | |||
| 7ae2bb7635 | |||
| a75f0662ad | |||
| ffd68d5037 | |||
| adf9e2334c | |||
| 4125811017 | |||
| 4e8356b072 |
@@ -374,29 +374,17 @@
|
||||
:href="`/actor/edit/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="link"
|
||||
>Edit bio</a>
|
||||
>Edit</a>
|
||||
|
||||
<a
|
||||
:href="`/actor/revs/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="link"
|
||||
>Revisions</a>
|
||||
|
||||
<span
|
||||
v-if="user && user.role !== 'user'"
|
||||
class="link"
|
||||
@click="showMergeDialog = true"
|
||||
>Merge</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<Merge
|
||||
v-if="showMergeDialog"
|
||||
:actors="[actor]"
|
||||
@close="showMergeDialog = false"
|
||||
/>
|
||||
|
||||
<div class="descriptions-container">
|
||||
<div
|
||||
v-if="descriptions.length > 0"
|
||||
@@ -457,8 +445,6 @@ import formatTemplate from 'template-format';
|
||||
import getPath from '#/src/get-path.js';
|
||||
import { formatDate } from '#/utils/format.js';
|
||||
|
||||
import Merge from '#/components/actors/merge.vue';
|
||||
|
||||
const expanded = ref(false);
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
@@ -545,8 +531,6 @@ const aliases = Object
|
||||
.toSorted(([, countA], [, countB]) => countB - countA)
|
||||
.map(([alias]) => alias)
|
||||
.filter((alias) => alias !== props.actor.name);
|
||||
|
||||
const showMergeDialog = ref(false);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -898,7 +882,7 @@ const showMergeDialog = ref(false);
|
||||
display: none;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
z-index: 1;
|
||||
bottom: -.25rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,10 @@
|
||||
</div>
|
||||
|
||||
<span class="label">
|
||||
<span class="name ellipsis">{{ actor.name }}</span>
|
||||
<span
|
||||
class="name ellipsis"
|
||||
:style="{ 'font-size': `${Math.max(0.9 + Math.min((17 - actor.name.length), 0) * 0.06, 0.65)}rem` }"
|
||||
>{{ actor.name }}</span>
|
||||
|
||||
<img
|
||||
v-if="actor.entity"
|
||||
@@ -82,6 +85,13 @@
|
||||
:src="`/logos/${actor.entity.slug}/favicon_dark.png`"
|
||||
class="favicon"
|
||||
>
|
||||
|
||||
<Icon
|
||||
v-if="actor.alias && actor.alias.name !== actor.name"
|
||||
v-tooltip="`Credited as '${actor.alias.name}'`"
|
||||
icon="at-sign"
|
||||
class="alias"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -148,6 +158,7 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
}
|
||||
|
||||
.label {
|
||||
height: 1.75rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@@ -161,7 +172,7 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
}
|
||||
|
||||
.name {
|
||||
padding: .35rem .25rem .35rem .5rem;
|
||||
padding: 0 .25rem 0 .5rem;
|
||||
}
|
||||
|
||||
.favicon {
|
||||
@@ -258,4 +269,11 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
height: .75rem;
|
||||
margin-left: .25rem;
|
||||
}
|
||||
|
||||
.alias {
|
||||
height: 100%;
|
||||
fill: var(--glass-weak-20);
|
||||
padding: 0 .25rem;
|
||||
cursor: help;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -19,10 +19,16 @@
|
||||
>{{ avatar.sharpness.toFixed(2) }}</span>
|
||||
</span>
|
||||
|
||||
<span
|
||||
:title="`Added ${format(avatar.createdAt, 'yyyy-MM-dd')}, may not reflect photo age`"
|
||||
class="avatar-date"
|
||||
>{{ format(avatar.createdAt, '\'\'yy-MM') }}</span>
|
||||
|
||||
<a
|
||||
:href="getPath(avatar)"
|
||||
target="_blank"
|
||||
class="avatar-zoom"
|
||||
@click.stop
|
||||
>
|
||||
<Icon
|
||||
icon="search"
|
||||
@@ -32,6 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { format } from 'date-fns';
|
||||
import getPath from '#/src/get-path.js';
|
||||
|
||||
defineProps({
|
||||
@@ -89,7 +96,8 @@ defineProps({
|
||||
}
|
||||
|
||||
.avatar-meta,
|
||||
.avatar-credit {
|
||||
.avatar-credit,
|
||||
.avatar-date {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
box-sizing: border-box;
|
||||
@@ -112,4 +120,10 @@ defineProps({
|
||||
bottom: .75rem;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.avatar-date {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -146,7 +146,6 @@ const { pageProps } = inject('pageContext');
|
||||
const {
|
||||
tag: pageTag,
|
||||
actor: pageActor,
|
||||
stash: pageStash,
|
||||
} = pageProps;
|
||||
|
||||
const search = ref('');
|
||||
@@ -177,7 +176,7 @@ const priorityTags = [
|
||||
'lesbian',
|
||||
];
|
||||
|
||||
const isActorTagsAvailable = computed(() => props.actorTags && (props.filters.actors.length > 0 || pageActor) && !pageStash);
|
||||
const isActorTagsAvailable = computed(() => props.actorTags && (props.filters.actors.length > 0 || pageActor));
|
||||
|
||||
const groupedTags = computed(() => {
|
||||
// can't show actor tags inside stash, because both require a join, and manticore currently only supports one
|
||||
@@ -225,6 +224,8 @@ const groupedTags = computed(() => {
|
||||
});
|
||||
|
||||
function toggleTag(tag, combine) {
|
||||
emit('update', 'onlyActorTags', showActorTags.value, false);
|
||||
|
||||
if (props.filters.tags.includes(tag.slug)) {
|
||||
emit('update', 'tags', props.filters.tags.filter((tagId) => tagId !== tag.slug));
|
||||
return;
|
||||
|
||||
@@ -287,6 +287,7 @@ const filters = ref({
|
||||
search: urlParsed.search.q,
|
||||
years: urlParsed.search.years?.split(',').filter(Boolean).map(Number) || [],
|
||||
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
|
||||
onlyActorTags: Object.hasOwn(urlParsed.search, 'at'),
|
||||
entity: queryEntity,
|
||||
actors: queryActors,
|
||||
});
|
||||
@@ -346,6 +347,7 @@ async function search(options = {}) {
|
||||
years: filters.value.years.join(',') || undefined,
|
||||
actors: filters.value.actors.map((filterActor) => getActorIdentifier(filterActor)).join(',') || undefined, // don't include page actor ID in query, already a parameter
|
||||
tags: filters.value.tags.join(',') || undefined,
|
||||
at: (filters.value.tags.length > 0 && filters.value.onlyActorTags) || undefined,
|
||||
// e: filters.value.entity?.type === 'network' ? `_${filters.value.entity.slug}` : (filters.value.entity?.slug || undefined),
|
||||
e: filters.value.entity ? `${entityPrefixes[filters.value.entity.type]}${filters.value.entity.slug}` : undefined,
|
||||
}, { redirect: false });
|
||||
@@ -355,6 +357,7 @@ async function search(options = {}) {
|
||||
years: filters.value.years.filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
actors: [pageActor, ...filters.value.actors].filter(Boolean).map((filterActor) => getActorIdentifier(filterActor)).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
tags: [pageTag?.slug, ...filters.value.tags].filter(Boolean).join(','),
|
||||
at: !!filters.value.onlyActorTags,
|
||||
stashId: pageStash?.id,
|
||||
e: entitySlug,
|
||||
scope: scope.value,
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "traxxx-web",
|
||||
"version": "0.50.15",
|
||||
"version": "0.51.8",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.50.15",
|
||||
"version": "0.51.8",
|
||||
"dependencies": {
|
||||
"@brillout/json-serializer": "^0.5.8",
|
||||
"@dicebear/collection": "^7.0.5",
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
"overrides": {
|
||||
"vite": "$vite"
|
||||
},
|
||||
"version": "0.50.15",
|
||||
"version": "0.51.8",
|
||||
"imports": {
|
||||
"#/*": "./*.js"
|
||||
}
|
||||
|
||||
@@ -55,11 +55,26 @@
|
||||
>
|
||||
<h2 class="heading ellipsis">Edit actor #{{ actor.id }} - {{ actor.name }}</h2>
|
||||
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="link noshrink"
|
||||
>Go to actor</a>
|
||||
<span class="header-actions">
|
||||
<span
|
||||
v-if="verifyAbility(user, 'actor', 'merge')"
|
||||
target="_blank"
|
||||
class="link noshrink"
|
||||
@click="showMergeDialog = true"
|
||||
>Merge</span>
|
||||
|
||||
<Merge
|
||||
v-if="showMergeDialog"
|
||||
:actors="[actor]"
|
||||
@close="showMergeDialog = false"
|
||||
/>
|
||||
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="link noshrink"
|
||||
>Go to actor</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -367,12 +382,15 @@ import EditPenis from '#/components/edit/penis.vue';
|
||||
import Avatar from '#/components/edit/avatar.vue';
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
import Ellipsis from '#/components/loading/ellipsis.vue';
|
||||
import Merge from '#/components/actors/merge.vue';
|
||||
|
||||
import {
|
||||
// get,
|
||||
post,
|
||||
} from '#/src/api.js';
|
||||
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
const user = pageContext.user;
|
||||
@@ -591,6 +609,7 @@ const comment = ref(null);
|
||||
const apply = ref(user.role !== 'user');
|
||||
const submitting = ref(false);
|
||||
const submitted = ref(false);
|
||||
const showMergeDialog = ref(false);
|
||||
|
||||
const sizeUnits = ref('metric');
|
||||
const figureUnits = ref('us');
|
||||
@@ -703,9 +722,21 @@ async function submit() {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
|
||||
.link {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.heading {
|
||||
margin: 0;
|
||||
}
|
||||
@@ -946,5 +977,9 @@ async function submit() {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-header {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,7 +45,13 @@
|
||||
:key="`actor-${actor.id}`"
|
||||
class="actor"
|
||||
>
|
||||
<td class="actor-id ellipsis">{{ actor.id }}</td>
|
||||
<td class="actor-id ellipsis">
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="nolink"
|
||||
>{{ actor.id }}</a>
|
||||
</td>
|
||||
|
||||
<td
|
||||
v-tooltip="actor.entity?.name || 'Global'"
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
|
||||
<Link
|
||||
:href="user?.abilities?.some((ability) => ability.subject === 'plainUrls') ? scene.url : scene.watchUrl"
|
||||
:href="verifyAbility(user, 'plainUrls') ? scene.url : scene.watchUrl"
|
||||
:title="scene.date ? formatDate(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${formatDate(scene.createdAt, 'y-MM-dd')}`"
|
||||
target="_blank"
|
||||
class="date nolink"
|
||||
@@ -140,30 +140,46 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tags">
|
||||
<div
|
||||
v-for="actorTags in tags"
|
||||
:key="`tags-${actorTags.actor?.slug || 'scene'}`"
|
||||
class="tags-section"
|
||||
<ul class="tags nolist">
|
||||
<li
|
||||
v-for="tag in tags"
|
||||
:key="`tag-${tag.id}`"
|
||||
class="tag"
|
||||
:class="{ 'has-actors': tag.actors.length > 0 }"
|
||||
>
|
||||
<ul class="nolist">
|
||||
<li
|
||||
v-if="actorTags.actor"
|
||||
class="tags-actor"
|
||||
>{{ actorTags.actor.name }}:</li>
|
||||
<Link
|
||||
:href="`/tag/${tag.slug}`"
|
||||
class="tag-name nolink"
|
||||
>{{ tag.name }}</Link>
|
||||
|
||||
<li
|
||||
v-for="tag in actorTags.tags"
|
||||
:key="`tag-${tag.id}`"
|
||||
<span
|
||||
v-if="tag.actors.length > 0"
|
||||
v-tooltip="{
|
||||
content: `For ${tag.actors.slice(0, -1).map((tagActor) => tagActor.name).join(', ')}${tag.actors.length > 0 ? ` and ${tag.actors.at(-1).name}` : ''}`,
|
||||
triggers: ['hover', 'click'],
|
||||
}"
|
||||
class="tag-actors"
|
||||
>
|
||||
<template
|
||||
v-for="tagActor in tag.actors"
|
||||
>
|
||||
<Link
|
||||
:href="`/tag/${tag.slug}`"
|
||||
class="tag nolink"
|
||||
>{{ tag.name }}</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="tagActor.avatar"
|
||||
:key="`tagactor-${tagActor.id}`"
|
||||
class="tag-avatar"
|
||||
:style="tagActor.avatarStyle"
|
||||
/>
|
||||
|
||||
<Icon
|
||||
v-else
|
||||
:key="`tagactor-${tagActor.id}`"
|
||||
icon="star-full"
|
||||
class="tag-star"
|
||||
/>
|
||||
</template>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div
|
||||
v-if="scene.movies.length > 0 || scene.series.length > 0"
|
||||
@@ -424,6 +440,8 @@ import Cookies from 'js-cookie';
|
||||
import { formatDate, formatDuration } from '#/utils/format.js';
|
||||
import events from '#/src/events.js';
|
||||
import processSummaryTemplate from '#/utils/process-summary-template.js';
|
||||
import getPath from '#/src/get-path.js';
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
import Banner from '#/components/media/banner.vue';
|
||||
import ActorTile from '#/components/actors/tile.vue';
|
||||
@@ -450,16 +468,164 @@ const {
|
||||
|
||||
const { scene } = pageProps;
|
||||
|
||||
const tags = [
|
||||
{
|
||||
tags: scene.tags.filter((tag) => tag.actorId === null),
|
||||
actor: null,
|
||||
},
|
||||
...scene.actors.map((actor) => ({
|
||||
actor,
|
||||
tags: scene.tags.filter((tag) => tag.actorId === actor.id),
|
||||
})),
|
||||
].filter((actorTags) => actorTags.tags.length > 0);
|
||||
const avatarFrameSize = 36;
|
||||
const avatarMargin = 2.75;
|
||||
const avatarVerticalOffset = 0.1; // fraction of crop size; positive shifts crop down (frames more chin, less forehead)
|
||||
const fallbackZoom = 2.25; // zoom level when no biometrics are available
|
||||
|
||||
function clampCrop(crop) {
|
||||
const size = Math.min(crop.size, crop.imageWidth, crop.imageHeight);
|
||||
|
||||
const maxLeft = Math.max(0, crop.imageWidth - size);
|
||||
const maxTop = Math.max(0, crop.imageHeight - size);
|
||||
|
||||
return {
|
||||
...crop,
|
||||
size,
|
||||
left: Math.min(Math.max(crop.left, 0), maxLeft),
|
||||
top: Math.min(Math.max(crop.top, 0), maxTop),
|
||||
};
|
||||
}
|
||||
|
||||
function getFaceCrop(biometrics) {
|
||||
if (!biometrics) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
box,
|
||||
leftEye,
|
||||
rightEye,
|
||||
mouth,
|
||||
width: imageWidth,
|
||||
height: imageHeight,
|
||||
} = biometrics;
|
||||
|
||||
if (!imageWidth || !imageHeight) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (leftEye && rightEye && mouth) {
|
||||
const avgEyeY = (leftEye[1] + rightEye[1]) / 2;
|
||||
const avgEyeX = (leftEye[0] + rightEye[0]) / 2;
|
||||
|
||||
const eyesToMouth = mouth[1] - avgEyeY;
|
||||
|
||||
const centerX = (avgEyeX + mouth[0]) / 2;
|
||||
const centerY = (avgEyeY + mouth[1]) / 2;
|
||||
|
||||
const size = eyesToMouth * avatarMargin;
|
||||
|
||||
return clampCrop({
|
||||
left: centerX - size / 2,
|
||||
top: centerY - size / 2 - size * avatarVerticalOffset,
|
||||
size,
|
||||
imageWidth,
|
||||
imageHeight,
|
||||
});
|
||||
}
|
||||
|
||||
// fallback to the plain detection box if landmarks are missing
|
||||
if (box) {
|
||||
const [x, y, width, height] = box;
|
||||
const size = Math.max(width, height);
|
||||
|
||||
return clampCrop({
|
||||
left: x + width / 2 - size / 2,
|
||||
top: y + height / 2 - size / 2 - size * avatarVerticalOffset,
|
||||
size,
|
||||
imageWidth,
|
||||
imageHeight,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getFallbackCrop(imageWidth, imageHeight) {
|
||||
const size = Math.min(imageWidth, imageHeight) / fallbackZoom;
|
||||
|
||||
return clampCrop({
|
||||
left: (imageWidth - size) / 2, // centered horizontally
|
||||
top: 0, // anchored to top
|
||||
size,
|
||||
imageWidth,
|
||||
imageHeight,
|
||||
});
|
||||
}
|
||||
|
||||
function getAvatarBackgroundStyle(actorAvatar) {
|
||||
if (!actorAvatar) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const avatarUrl = getPath(actorAvatar, 'thumbnail');
|
||||
const crop = getFaceCrop(actorAvatar.biometrics)
|
||||
|| (actorAvatar.width && actorAvatar.height ? getFallbackCrop(actorAvatar.width, actorAvatar.height) : null);
|
||||
|
||||
if (!crop) {
|
||||
// no dimensions available at all — last-resort plain cover
|
||||
return {
|
||||
backgroundImage: `url(${avatarUrl})`,
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
};
|
||||
}
|
||||
|
||||
const scale = avatarFrameSize / crop.size;
|
||||
|
||||
const backgroundWidth = crop.imageWidth * scale;
|
||||
const backgroundHeight = crop.imageHeight * scale;
|
||||
const backgroundPositionX = -(crop.left * scale);
|
||||
const backgroundPositionY = -(crop.top * scale);
|
||||
|
||||
return {
|
||||
backgroundImage: `url(${avatarUrl})`,
|
||||
backgroundSize: `${backgroundWidth}px ${backgroundHeight}px`,
|
||||
backgroundPosition: `${backgroundPositionX}px ${backgroundPositionY}px`,
|
||||
backgroundRepeat: 'no-repeat',
|
||||
};
|
||||
}
|
||||
|
||||
const actorsById = Object.fromEntries(scene.actors.map((actor) => {
|
||||
const curatedActor = {
|
||||
...actor,
|
||||
avatarStyle: getAvatarBackgroundStyle(actor.avatar),
|
||||
};
|
||||
|
||||
return [actor.id, curatedActor];
|
||||
}));
|
||||
|
||||
const tags = Array.from(scene.tags
|
||||
.reduce((acc, tag) => {
|
||||
const accTag = acc.get(tag.id);
|
||||
|
||||
if (accTag && tag.actorId) {
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [...accTag.actors, actorsById[tag.actorId]].toSorted((actorA, actorB) => actorA.name.localeCompare(actorB.name)),
|
||||
});
|
||||
}
|
||||
|
||||
if (accTag) {
|
||||
// shouldn't happen, but account for it
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (tag.actorId) {
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [actorsById[tag.actorId]],
|
||||
});
|
||||
}
|
||||
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [],
|
||||
});
|
||||
}, new Map())
|
||||
.values());
|
||||
|
||||
const showSummaryDialog = ref(false);
|
||||
|
||||
@@ -664,7 +830,7 @@ function copySummary() {
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .25rem 1rem;
|
||||
gap: .35rem;
|
||||
}
|
||||
|
||||
.tags-section {
|
||||
@@ -684,25 +850,70 @@ function copySummary() {
|
||||
overflow-x: auto;
|
||||
|
||||
.actor {
|
||||
width: 10rem;
|
||||
width: 9rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: .5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: .25rem;
|
||||
margin: 0 .25rem .25rem 0;
|
||||
background: var(--background);
|
||||
box-shadow: 0 0 3px var(--shadow-weak-30);
|
||||
overflow: hidden;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 0 3px var(--shadow-weak-20);
|
||||
}
|
||||
}
|
||||
|
||||
.tag-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: .5rem;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary);
|
||||
box-shadow: 0 0 3px var(--shadow-weak-20);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-actors {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 .1rem;
|
||||
}
|
||||
|
||||
.tag-avatar {
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
margin: 0.1rem .05rem;
|
||||
border-radius: .25rem;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
box-shadow: inset 0 0 3px var(--shadow-weak-20);
|
||||
border-radius: inherit;
|
||||
pointer-events: none; /* so it doesn't block hover/click on the image */
|
||||
}
|
||||
}
|
||||
|
||||
.tag-star {
|
||||
padding: .625rem .625rem;
|
||||
}
|
||||
|
||||
.tag-star {
|
||||
height: 100%;
|
||||
fill: var(--primary);
|
||||
}
|
||||
|
||||
.movies,
|
||||
.series {
|
||||
display: grid;
|
||||
|
||||
@@ -253,6 +253,7 @@ import EditMovies from '#/components/edit/movies.vue';
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
|
||||
import { post } from '#/src/api.js';
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
@@ -273,9 +274,11 @@ const fields = computed(() => [
|
||||
note: 'Actor-specific tags should only be used where confusion is reasonable, such as group scenes in which some perform anal, and some don\'t.',
|
||||
},
|
||||
{
|
||||
key: 'movies',
|
||||
type: 'movies',
|
||||
value: scene.value.movies,
|
||||
key: 'url',
|
||||
label: 'URL',
|
||||
type: 'string',
|
||||
value: scene.value.url,
|
||||
enabled: verifyAbility(user, 'scene', 'update'),
|
||||
},
|
||||
{
|
||||
key: 'title',
|
||||
@@ -316,23 +319,26 @@ const fields = computed(() => [
|
||||
precision: scene.value.productionDatePrecision, // not currently implemented
|
||||
},
|
||||
},
|
||||
...(user.role === 'user'
|
||||
? []
|
||||
: [
|
||||
{
|
||||
key: 'comment',
|
||||
type: 'text',
|
||||
placeholder: 'Do NOT use this field to summarize and clarify your revision. This field is for permanent notes and comments regarding the scene or database entry itself.',
|
||||
value: scene.value.comment,
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
type: 'checkbox',
|
||||
checkboxLabel: 'Remove this scene from the database',
|
||||
value: false,
|
||||
},
|
||||
]),
|
||||
]);
|
||||
{
|
||||
key: 'movies',
|
||||
type: 'movies',
|
||||
value: scene.value.movies,
|
||||
},
|
||||
{
|
||||
key: 'comment',
|
||||
type: 'text',
|
||||
placeholder: 'Do NOT use this field to summarize and clarify your revision. This field is for permanent notes and comments regarding the scene or database entry itself.',
|
||||
value: scene.value.comment,
|
||||
enabled: verifyAbility(user, 'scene', 'update'),
|
||||
},
|
||||
{
|
||||
key: 'delete',
|
||||
type: 'checkbox',
|
||||
checkboxLabel: 'Remove this scene from the database',
|
||||
value: false,
|
||||
enabled: verifyAbility(user, 'scene', 'delete'),
|
||||
},
|
||||
].filter((field) => field.enabled !== false));
|
||||
|
||||
function simplifyArray(field) {
|
||||
if (Array.isArray(field.value) && field.simplify !== false) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="header">
|
||||
<h2 class="title">{{ tag.name }}</h2>
|
||||
<h2
|
||||
:title="`${tag.name} (#${tag.id})`"
|
||||
class="title"
|
||||
>{{ tag.name }}</h2>
|
||||
|
||||
<Heart
|
||||
domain="tags"
|
||||
|
||||
113
src/actors.js
113
src/actors.js
@@ -62,11 +62,22 @@ const keyMap = {
|
||||
const socialsOrder = ['onlyfans', 'fansly', 'twitter', 'instagram', 'loyalfans', 'manyvids', 'pornhub', 'linktree', null];
|
||||
|
||||
export function curateActor(actor, context = {}) {
|
||||
if (!actor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: actor.id,
|
||||
slug: actor.slug,
|
||||
name: actor.name,
|
||||
aliases: actor.aliases || [],
|
||||
aliases: actor.aliases || [], // used for profile pages
|
||||
alias: actor.alias
|
||||
? {
|
||||
id: actor.alias.id,
|
||||
slug: actor.alias.slug,
|
||||
name: actor.alias.name,
|
||||
}
|
||||
: null,
|
||||
gender: actor.gender,
|
||||
age: actor.age,
|
||||
ethnicity: actor.ethnicity,
|
||||
@@ -132,6 +143,7 @@ export function curateActor(actor, context = {}) {
|
||||
avatar: actor.avatar && curateMedia({
|
||||
...actor.avatar,
|
||||
sfw_media: actor.sfw_avatar,
|
||||
biometrics: actor.biometrics,
|
||||
}),
|
||||
allowGlobalMatch: actor.allow_global_match,
|
||||
socials: context.socials?.map((social) => ({
|
||||
@@ -235,6 +247,7 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
knex.raw('row_to_json(entities) as entity'),
|
||||
knex.raw('row_to_json(sfw_media) as sfw_avatar'),
|
||||
knex.raw('json_agg(aliases) filter (where aliases.id is not null) as aliases'),
|
||||
knex.raw('row_to_json(media_biometrics) as biometrics'),
|
||||
)
|
||||
.leftJoin('actors_meta', 'actors_meta.actor_id', 'actors.id')
|
||||
.leftJoin('actors as aliases', 'aliases.alias_for', 'actors.id')
|
||||
@@ -242,8 +255,9 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
.leftJoin('countries as residence_countries', 'residence_countries.alpha2', 'actors.residence_country_alpha2')
|
||||
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
||||
.leftJoin('media_biometrics', 'media_biometrics.media_id', 'actors.avatar_media_id')
|
||||
.leftJoin('entities', 'entities.id', 'actors.entity_id')
|
||||
.groupBy('actors.id', 'avatars.id', 'sfw_media.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2');
|
||||
.groupBy('actors.id', 'avatars.id', 'sfw_media.id', 'media_biometrics.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2');
|
||||
}
|
||||
}),
|
||||
knex('actors_profiles')
|
||||
@@ -598,13 +612,18 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
|
||||
const trx = await knex.transaction();
|
||||
|
||||
let mergedProfiles;
|
||||
let mergedScenes;
|
||||
let mergedProfiles = [];
|
||||
let mergedSceneActors = [];
|
||||
let existingSceneActors = [];
|
||||
let duplicateSourceActors = [];
|
||||
let mergedActorStashes = [];
|
||||
|
||||
try {
|
||||
const [existingProfiles] = await Promise.all([
|
||||
const [existingProfiles, sourceProfiles] = await Promise.all([
|
||||
trx('actors_profiles')
|
||||
.where('actor_id', targetActorId),
|
||||
trx('actors_profiles')
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
trx('actors')
|
||||
.update('alias_for', targetActorId)
|
||||
.whereIn('id', sourceActorIds)
|
||||
@@ -613,19 +632,50 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
trx('actors_avatars')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
trx('stashes_actors')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.returning('id'),
|
||||
]);
|
||||
|
||||
// multiple source actors may provide profiles for the same entity, but we can only assign one to the target actor; prefer the newest
|
||||
const newestSourceProfileMap = Object.fromEntries(sourceProfiles
|
||||
.toSorted((profileA, profileB) => profileA.updated_at - profileB.updated_at)
|
||||
.map((profile) => [profile.entity_id, profile.id]));
|
||||
|
||||
const duplicateSourceProfiles = sourceProfiles.filter((profile) => newestSourceProfileMap[profile.entity_id] && newestSourceProfileMap[profile.entity_id] !== profile.id);
|
||||
|
||||
// assign source actor profiles to target actor, unless a profile for that entity is already present
|
||||
mergedProfiles = await trx('actors_profiles')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.whereNotIn('entity_id', existingProfiles.map((profile) => profile.entity_id))
|
||||
.whereNotIn('id', duplicateSourceProfiles.map((profile) => profile.id))
|
||||
.returning('id');
|
||||
|
||||
mergedScenes = await trx('releases_actors')
|
||||
// find releases that have more than one source actor assigned
|
||||
duplicateSourceActors = await trx('releases_actors')
|
||||
.select('release_id', knex.raw('array_agg(actor_id) as actor_ids'))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.groupBy('release_id')
|
||||
.having(trx.raw('COUNT(DISTINCT actor_id) > 1'));
|
||||
|
||||
if (duplicateSourceActors.length > 0) {
|
||||
// some scenes have multiple source actors assigned, which will cause a conflict after merging; we will need to remove all but one
|
||||
await trx('releases_actors')
|
||||
.whereIn('release_id', duplicateSourceActors.map((sceneActor) => sceneActor.release_id))
|
||||
.whereIn('actor_id', duplicateSourceActors.flatMap((sceneActor) => sceneActor.actor_ids.slice(1)))
|
||||
.delete();
|
||||
}
|
||||
|
||||
// find scenes that already have target actor assigned
|
||||
existingSceneActors = await trx('releases_actors')
|
||||
.where('actor_id', targetActorId);
|
||||
|
||||
// delete release source actors for scenes that already have the target actor assigned
|
||||
await trx('releases_actors')
|
||||
.whereIn('release_id', existingSceneActors.map((sceneActor) => sceneActor.release_id))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.delete();
|
||||
|
||||
// alias release source actors to target actors
|
||||
mergedSceneActors = await trx('releases_actors')
|
||||
.update({
|
||||
actor_id: targetActorId,
|
||||
alias_id: knex.raw('actor_id'),
|
||||
@@ -633,6 +683,40 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.returning('release_id');
|
||||
|
||||
const [targetActorStashes, sourceActorStashes] = await Promise.all([
|
||||
trx('stashes_actors')
|
||||
.where('actor_id', targetActorId),
|
||||
trx('stashes_actors')
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
]);
|
||||
|
||||
// remove source actors from stashes that already contain target actor
|
||||
await trx('stashes_actors')
|
||||
.whereIn('stash_id', targetActorStashes.map((stash) => stash.stash_id))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.delete();
|
||||
|
||||
// find stashes that have more than one source actor assigned
|
||||
const duplicateStashActors = await trx('stashes_actors')
|
||||
.select('stash_id', knex.raw('array_agg(actor_id order by created_at) as actor_ids'))
|
||||
.whereIn('actor_id', sourceActorStashes.map((actorStash) => actorStash.actor_id))
|
||||
.groupBy('stash_id')
|
||||
.having(trx.raw('COUNT(DISTINCT actor_id) > 1'));
|
||||
|
||||
if (duplicateStashActors.length > 0) {
|
||||
// some stashes have multiple source actors assigned, which will cause a conflict after merging; we will need to remove all but one
|
||||
await trx('stashes_actors')
|
||||
.whereIn('stash_id', duplicateStashActors.map((actorStash) => actorStash.stash_id))
|
||||
.whereIn('actor_id', duplicateStashActors.flatMap((actorStash) => actorStash.actor_ids.slice(1)))
|
||||
.delete();
|
||||
}
|
||||
|
||||
// we update an existing entry instead of creating a new one, so the original stash date is preserved
|
||||
mergedActorStashes = await trx('stashes_actors')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.returning('stash_id');
|
||||
|
||||
await trx.commit();
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
@@ -649,14 +733,19 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
}, { refreshView: false });
|
||||
|
||||
await Promise.all([
|
||||
syncScenes(mergedScenes.map((scene) => scene.release_id)),
|
||||
syncScenes([
|
||||
...mergedSceneActors.map((sceneActor) => sceneActor.release_id),
|
||||
...existingSceneActors.map((sceneActor) => sceneActor.release_id),
|
||||
...duplicateSourceActors.map((sceneActor) => sceneActor.release_id),
|
||||
]),
|
||||
syncActors([targetActorId, ...sourceActorIds]),
|
||||
syncStashes('actor', [targetActorId, ...sourceActorIds]),
|
||||
]);
|
||||
|
||||
return {
|
||||
scenes: mergedScenes.length,
|
||||
scenes: mergedSceneActors.length,
|
||||
profiles: mergedProfiles.length,
|
||||
stashes: mergedActorStashes.length,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import initServer from './web/server.js';
|
||||
import { initCaches } from './cache.js';
|
||||
import { initSyncCron } from './sync.js';
|
||||
|
||||
async function init() {
|
||||
await initCaches();
|
||||
|
||||
initServer();
|
||||
initSyncCron();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
@@ -32,5 +32,13 @@ export function curateMedia(media, context = {}) {
|
||||
type: context.type || null,
|
||||
sfw: curateMedia(media.sfw_media),
|
||||
isRestricted: context.isRestricted,
|
||||
biometrics: media.biometrics
|
||||
? {
|
||||
...media.biometrics.biometrics,
|
||||
width: media.biometrics.width,
|
||||
height: media.biometrics.height,
|
||||
}
|
||||
: null,
|
||||
createdAt: media.created_at,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -209,16 +209,21 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
'actors.*',
|
||||
knex.raw('row_to_json(avatars) as avatar'),
|
||||
knex.raw('row_to_json(sfw_media) as sfw_avatar'),
|
||||
knex.raw('row_to_json(media_biometrics) as biometrics'),
|
||||
knex.raw('row_to_json(aliases) as alias'),
|
||||
knex.raw('case when aliases.id is not null then json_build_object(\'id\', aliases.id, \'name\', aliases.name, \'slug\', aliases.slug) end as alias'),
|
||||
'countries.name as birth_country_name',
|
||||
'countries.alias as birth_country_alias',
|
||||
'releases_actors.release_id',
|
||||
)
|
||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
|
||||
.leftJoin('actors as aliases', 'aliases.id', 'releases_actors.alias_id')
|
||||
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
||||
.leftJoin('media_biometrics', 'media_biometrics.media_id', 'actors.avatar_media_id')
|
||||
.leftJoin('countries', 'countries.alpha2', 'actors.birth_country_alpha2')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.groupBy('actors.id', 'releases_actors.release_id', 'avatars.id', 'countries.name', 'countries.alias', 'sfw_media.id'),
|
||||
.groupBy('actors.id', 'aliases.id', 'releases_actors.release_id', 'avatars.id', 'media_biometrics.id', 'countries.name', 'countries.alias', 'sfw_media.id'),
|
||||
directors: knex('releases_directors')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('actors as directors', 'directors.id', 'releases_directors.director_id'),
|
||||
@@ -415,6 +420,20 @@ function curateFacet(results, field) {
|
||||
|| [];
|
||||
}
|
||||
|
||||
const packN = 100_000;
|
||||
|
||||
function mergePackedTags(tags) {
|
||||
const mergedCounts = tags.reduce((merged, tag) => {
|
||||
const tagId = tag.key % packN;
|
||||
|
||||
merged.set(tagId, (merged.get(tagId) ?? 0) + tag.doc_count);
|
||||
|
||||
return merged;
|
||||
}, new Map());
|
||||
|
||||
return Array.from(mergedCounts.entries(), ([key, count]) => ({ key, doc_count: count }));
|
||||
}
|
||||
|
||||
async function queryManticoreSql(filters, options, _reqUser) {
|
||||
const aggSize = config.database.manticore.maxAggregateSize;
|
||||
|
||||
@@ -437,7 +456,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
:yearsFacet:
|
||||
:actorsFacet:
|
||||
:tagsFacet:
|
||||
:actorTagsFacet:
|
||||
:channelsFacet:
|
||||
:studiosFacet:;
|
||||
show meta;
|
||||
@@ -470,11 +488,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
year(scenes.effective_date) as effective_year,
|
||||
weight() as _score
|
||||
`));
|
||||
|
||||
// manticore only supports one joined table, so we can't use it inside stashes
|
||||
builder
|
||||
.leftJoin('scenes_tags', 'scenes_tags.scene_id', 'scenes_.id')
|
||||
.groupBy('scenes.id');
|
||||
}
|
||||
|
||||
if (filters.query) {
|
||||
@@ -487,7 +500,17 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
}
|
||||
|
||||
filters.tagIds?.forEach((tagId) => {
|
||||
builder.where('any(tag_ids)', tagId);
|
||||
if (filters.onlyActorTags) {
|
||||
builder.where((whereBuilder) => {
|
||||
whereBuilder.where('any(assigned_tag_ids)', tagId);
|
||||
|
||||
filters.actorIds?.forEach((actorId) => {
|
||||
whereBuilder.orWhere('any(assigned_tag_ids)', actorId * 1_000_00 + tagId);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
builder.where('any(tag_ids)', tagId);
|
||||
}
|
||||
});
|
||||
|
||||
if (filters.notTagIds) {
|
||||
@@ -530,12 +553,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
builder.where('scenes.is_showcased', filters.isShowcased);
|
||||
}
|
||||
|
||||
/*
|
||||
if (filters.isShowcased) {
|
||||
builder.where('scenes.date', '>', 0);
|
||||
}
|
||||
*/
|
||||
|
||||
if (options.dedupe) {
|
||||
builder.where('scenes.dupe_index', '<', 2);
|
||||
}
|
||||
@@ -580,11 +597,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
// option threads=1 fixes actors, but drastically slows down performance, wait for fix
|
||||
yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null,
|
||||
actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
// don't facet tags associated to other actors, actor ID 0 means global
|
||||
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary
|
||||
? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(*) desc limit ?`, [aggSize])
|
||||
: null,
|
||||
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.assigned_tag_ids as tags_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
maxMatches: config.database.manticore.maxMatches,
|
||||
@@ -607,10 +620,26 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
const years = curateFacet(results, 'years_facet');
|
||||
const actorIds = curateFacet(results, 'actors_facet');
|
||||
const tagIds = curateFacet(results, 'tags_facet');
|
||||
const actorTagIds = curateFacet(results, 'actor_tags_facet');
|
||||
const channelIds = curateFacet(results, 'channels_facet');
|
||||
const studioIds = curateFacet(results, 'studios_facet');
|
||||
|
||||
const allTagIds = mergePackedTags(tagIds);
|
||||
|
||||
const actorTagIds = mergePackedTags(tagIds.filter((tag) => {
|
||||
if (tag.key < packN || !filters?.actorIds.length) {
|
||||
// global
|
||||
return true;
|
||||
}
|
||||
|
||||
const tagActorId = Math.floor(tag.key / packN);
|
||||
|
||||
if (filters.actorIds.includes(tagActorId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}));
|
||||
|
||||
const total = Number(results.at(-1).data.find((entry) => entry.Variable_name === 'total_found')?.Value) || 0;
|
||||
|
||||
return {
|
||||
@@ -619,7 +648,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
aggregations: {
|
||||
years,
|
||||
actorIds,
|
||||
tagIds,
|
||||
tagIds: allTagIds,
|
||||
actorTagIds,
|
||||
channelIds,
|
||||
studioIds,
|
||||
@@ -853,6 +882,7 @@ async function applySceneRevision(revisionIds, reqUser) {
|
||||
'title',
|
||||
'description',
|
||||
'date',
|
||||
'url',
|
||||
'datePrecision',
|
||||
'duration',
|
||||
'productionDate',
|
||||
|
||||
41
src/sync.js
41
src/sync.js
@@ -114,7 +114,8 @@ export async function syncManticoreScenes(sceneIds) {
|
||||
studios.name as studio_name,
|
||||
grandparents.id as parent_network_id,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
||||
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors_aliases.id, actors_aliases.name)) FILTER (WHERE actors_aliases.id IS NOT NULL), '[]') as actors_aliases,
|
||||
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 (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
|
||||
@@ -135,6 +136,7 @@ export async function syncManticoreScenes(sceneIds) {
|
||||
LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = releases.id
|
||||
LEFT JOIN actors ON local_actors.actor_id = actors.id
|
||||
LEFT JOIN actors AS directors ON local_directors.director_id = directors.id
|
||||
LEFT JOIN actors AS actors_aliases ON actors_aliases.alias_for = actors.id
|
||||
LEFT JOIN tags ON local_tags.tag_id = tags.id
|
||||
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
|
||||
LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id
|
||||
@@ -185,6 +187,18 @@ 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]);
|
||||
|
||||
// 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
|
||||
// f1 = tag ID, f5 = actor ID
|
||||
const assignedTagIds = scene.tags.map((tag) => (tag.f5 === null ? tag.f1 : tag.f5 * 1_000_00 + tag.f1));
|
||||
|
||||
/*
|
||||
if (sceneId === '187734') {
|
||||
console.log(scene, assignedTagIds);
|
||||
throw new Error('ABORT');
|
||||
}
|
||||
*/
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
@@ -207,9 +221,10 @@ export async function syncManticoreScenes(sceneIds) {
|
||||
studio_slug: scene.studio_slug || undefined,
|
||||
studio_name: scene.studio_name || undefined,
|
||||
entity_ids: [scene.channel_id, scene.network_id, scene.parent_network_id, scene.studio_id].filter(Boolean), // manticore does not support OR, this allows IN
|
||||
actor_ids: scene.actors.map((actor) => actor.f1),
|
||||
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||
actor_ids: scene.actors.map((actor) => actor.f1), // don't include aliases in ID or they would show up in filters
|
||||
actors: Array.from(new Set([...scene.actors.map((actor) => actor.f2), ...scene.actors_aliases.map((actor) => actor.f2)])).join(),
|
||||
tag_ids: Array.from(new Set(scene.tags.map((tag) => tag.f1))),
|
||||
assigned_tag_ids: assignedTagIds,
|
||||
tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results
|
||||
movie_ids: scene.movies.map((movie) => movie.f1),
|
||||
movies: scene.movies.map((movie) => movie.f2).join(' '),
|
||||
@@ -470,11 +485,13 @@ export async function syncQueue() {
|
||||
logger[process.tasks > 0 ? 'info' : 'verbose'](`Processed ${tasks.length} sync items`);
|
||||
}
|
||||
|
||||
CronJob.from({
|
||||
cronTime: config.sync.crontab,
|
||||
async onTick() {
|
||||
syncQueue();
|
||||
},
|
||||
start: config.sync.enabled,
|
||||
runOnInit: true,
|
||||
});
|
||||
export function initSyncCron() {
|
||||
CronJob.from({
|
||||
cronTime: config.sync.crontab,
|
||||
async onTick() {
|
||||
syncQueue();
|
||||
},
|
||||
start: config.sync.enabled,
|
||||
runOnInit: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ export async function curateScenesQuery(query) {
|
||||
notActorIds: splitActors.filter((actor) => actor.charAt(0) === '!').map((identifier) => parseActorIdentifier(identifier.slice(1))?.id).filter(Boolean),
|
||||
tagIds,
|
||||
notTagIds: notTagIds.filter((tagId) => !tagIds.includes(tagId)), // included tags get priority over excluded tags
|
||||
onlyActorTags: !!query.at,
|
||||
entityId,
|
||||
notEntityIds,
|
||||
movieId: Number(query.movieId) || null,
|
||||
|
||||
@@ -25,6 +25,7 @@ async function init() {
|
||||
actor_ids multi,
|
||||
actors text,
|
||||
tag_ids multi,
|
||||
assigned_tag_ids multi64,
|
||||
tags text,
|
||||
movie_ids multi,
|
||||
movies text,
|
||||
@@ -41,12 +42,15 @@ async function init() {
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists scenes_tags');
|
||||
|
||||
/* legacy, using packed decimal keys now
|
||||
await utilsApi.sql(`create table scenes_tags (
|
||||
id int,
|
||||
scene_id int,
|
||||
tag_id int,
|
||||
actor_id int
|
||||
)`);
|
||||
*/
|
||||
|
||||
console.log('Recreated scenes tables, syncing scenes...');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user