Compare commits

..
38 Commits
Author SHA1 Message Date
DebaucheryLibrarian a42a0fdf6d 0.59.2 2026-11-12 02:18:20 +01:00
DebaucheryLibrarian f5e3a8a2ae Added manticore sync all tool, updated manticore driver. 2026-11-12 02:18:13 +01:00
DebaucheryLibrarian de05075def 0.59.1 2026-11-12 01:54:14 +01:00
DebaucheryLibrarian d4817e9c9c Fixed scene tile actor title tooltip not showing unidentified actor's gender. 2026-11-12 01:54:11 +01:00
DebaucheryLibrarian a53c83eb98 0.59.0 2026-11-12 00:57:34 +01:00
DebaucheryLibrarian 810b2971a8 Improved scenes and movies meta header layout and responsiveness. 2026-11-12 00:57:30 +01:00
DebaucheryLibrarian a8f6bcb4f0 0.58.1 2026-11-11 23:28:56 +01:00
DebaucheryLibrarian 5a9ca8710b Changed scene year filter to range input. 2026-11-11 23:28:53 +01:00
DebaucheryLibrarian 91a5ad55cc 0.58.0 2026-11-11 22:23:55 +01:00
DebaucheryLibrarian 76ccd3729f Added unidentified actors and actor count filters. 2026-11-11 22:23:50 +01:00
DebaucheryLibrarian 10ac366e87 0.57.25 2026-09-22 02:22:21 +02:00
DebaucheryLibrarian a5e06b51ea Fixed scene serie poster curation and tile display. 2026-09-22 02:22:19 +02:00
DebaucheryLibrarian b3dcb65871 0.57.24 2026-09-22 00:54:23 +02:00
DebaucheryLibrarian 4527bf2495 Fixed alerts cron never initializing due missing config. 2026-09-22 00:54:22 +02:00
DebaucheryLibrarian 6c0e4d5456 0.57.23 2026-09-20 19:11:32 +02:00
DebaucheryLibrarian 8dd136446d Changed Chapter GraphQL type to accommodate video-type chapters without a starting time. 2026-09-20 19:11:30 +02:00
DebaucheryLibrarian 1cc94d665a 0.57.22 2026-09-18 23:25:51 +02:00
DebaucheryLibrarian a9d9b7623d Added actor date of birth and death precision. 2026-09-18 23:25:49 +02:00
DebaucheryLibrarian 83c0f1e4c6 0.57.21 2026-09-18 16:11:29 +02:00
DebaucheryLibrarian 64b92536d5 Fixed dark theme text color for revision count. 2026-09-18 16:11:27 +02:00
DebaucheryLibrarian cea5b98bda 0.57.20 2026-09-18 03:37:06 +02:00
DebaucheryLibrarian 411cde7cf9 Extended revision pagination to scene and actor pages, fixes 'revisions' label without count. 2026-09-18 03:37:03 +02:00
DebaucheryLibrarian 73d65ae873 0.57.19 2026-09-18 03:31:32 +02:00
DebaucheryLibrarian b5e9886b9b Added pagination and total to revisions. 2026-09-18 03:31:28 +02:00
DebaucheryLibrarian cd10f14285 0.57.18 2026-09-17 02:17:34 +02:00
DebaucheryLibrarian 514ed235a4 Added a default og:description. 2026-09-17 02:17:32 +02:00
DebaucheryLibrarian 00c6d17aaa 0.57.17 2026-09-17 01:17:06 +02:00
DebaucheryLibrarian de0b1c2baf Added scene chapters to GraphQL. Verifying API credential types. 2026-09-17 01:17:03 +02:00
DebaucheryLibrarian e9b7bb03d0 0.57.16 2026-08-17 00:06:56 +02:00
DebaucheryLibrarian 1e7207160c Fixed alert stash not syncing to manticore. 2026-08-17 00:06:53 +02:00
DebaucheryLibrarian 37a919770a 0.57.15 2026-07-28 23:46:12 +02:00
DebaucheryLibrarian 4e59994806 Fixed notify stash manticoresearch call still using obsolete 'index' key. 2026-07-28 23:46:10 +02:00
DebaucheryLibrarian 699f7f0944 0.57.14 2026-07-26 03:40:37 +02:00
DebaucheryLibrarian bf220f6b4e Added stash archiving. 2026-07-26 03:40:32 +02:00
DebaucheryLibrarian 02ee99d52f 0.57.13 2026-07-26 03:15:52 +02:00
DebaucheryLibrarian e50dedca66 Fixed profile page breaking when logged out. 2026-07-26 03:15:50 +02:00
DebaucheryLibrarian 760025f414 0.57.12 2026-07-26 00:26:51 +02:00
DebaucheryLibrarian 07d9dfaaaa Added stash sorting to stash tooltip menu and profile page. 2026-07-26 00:26:49 +02:00
66 changed files with 1857 additions and 388 deletions
+1
View File
@@ -69,6 +69,7 @@
--male: #0af;
--female: #f0a;
--trans: #a0f;
--enabled: #5c2;
--enabled-background: rgba(0, 255, 0, .1);
+1 -1
View File
@@ -87,7 +87,7 @@
}
.v-popper__popper[data-popper-placement^="top"] .v-popper__arrow-container {
bottom: -7px;
bottom: -6px;
}
.v-popper__popper[data-popper-placement^="top"] .v-popper__arrow-inner,
+5
View File
@@ -0,0 +1,5 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path d="M15.89 10.188l-4-5c-0.172-0.216-0.487-0.251-0.703-0.078s-0.251 0.487-0.078 0.703l3.89 4.863v0.325h-3.5l-2 2h-3l-2-2h-3.5v-0.325l3.89-4.863c0.173-0.216 0.138-0.53-0.078-0.703s-0.53-0.138-0.703 0.078l-4 5c-0.071 0.089-0.11 0.199-0.11 0.312v4.5c0 0.552 0.448 1 1 1h14c0.552 0 1-0.448 1-1v-4.5c0-0.114-0.039-0.224-0.11-0.312z"></path>
<path d="M8 0.5l-3.5 3.5h2.5v5h2v-5h2.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 528 B

+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg3"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs3" /><path
d="M5 12v-12h-2v12h-2.5l3.5 3.5 3.5-3.5h-2.5z"
id="path1" /><path
id="path1-3"
style="stroke-width:0.348033"
d="M 10.443359 2.2773438 C 10.354073 2.2861032 10.283203 2.3587981 10.283203 2.4472656 L 10.283203 4.328125 L 8.3339844 4.328125 C 8.2362054 4.328125 8.1582031 4.4056346 8.1582031 4.5 L 8.1582031 5.5253906 C 8.1582031 5.6197556 8.2362047 5.6953125 8.3339844 5.6953125 L 10.283203 5.6953125 L 10.283203 7.5292969 L 11.556641 6.46875 A 0.14617623 0.14617623 0 0 0 11.556641 6.4667969 C 11.601003 6.4299705 11.650097 6.3991617 11.701172 6.375 L 11.701172 5.6953125 L 13.648438 5.6953125 C 13.746218 5.6953125 13.826172 5.619755 13.826172 5.5253906 L 13.826172 4.5 C 13.826172 4.405635 13.746225 4.328125 13.648438 4.328125 L 11.701172 4.328125 L 11.701172 2.4472656 C 11.701172 2.3529006 11.621224 2.2773437 11.523438 2.2773438 L 10.460938 2.2773438 C 10.454826 2.2773438 10.449312 2.2767598 10.443359 2.2773438 z " /><path
d="M 16,5 C 16,2.243 13.757,0 11,0 8.243,0 6,2.243 6,5 V 5.5 C 6,5.776 6.224,6 6.5,6 6.776,6 7,5.776 7,5.5 V 5 c 0,-2.206 1.794,-4 4,-4 2.206,0 4,1.794 4,4 0,1.86 -1.277,3.428 -3,3.873 V 7 L 9,9.5 12,12 V 9.899 C 14.279,9.434 16,7.414 16,5 Z"
id="path3" /></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg3"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs3" /><path
d="M5 12v-12h-2v12h-2.5l3.5 3.5 3.5-3.5h-2.5z"
id="path1" /><path
id="path1-3"
style="stroke-width:0.348033"
d="M 10.443359 2.2773438 C 10.354073 2.2861032 10.283203 2.3587981 10.283203 2.4472656 L 10.283203 4.328125 L 8.3339844 4.328125 C 8.2362054 4.328125 8.1582031 4.4056346 8.1582031 4.5 L 8.1582031 5.5253906 C 8.1582031 5.6197556 8.2362047 5.6953125 8.3339844 5.6953125 L 10.283203 5.6953125 L 10.283203 6.3671875 C 10.340222 6.3923929 10.394355 6.4261166 10.443359 6.4667969 A 0.14617623 0.14617623 0 0 1 10.443359 6.46875 L 11.701172 7.5175781 L 11.701172 5.6953125 L 13.648438 5.6953125 C 13.746218 5.6953125 13.826172 5.619755 13.826172 5.5253906 L 13.826172 4.5 C 13.826172 4.405635 13.746225 4.328125 13.648438 4.328125 L 11.701172 4.328125 L 11.701172 2.4472656 C 11.701172 2.3529006 11.621224 2.2773437 11.523438 2.2773438 L 10.460938 2.2773438 C 10.454826 2.2773438 10.449312 2.2767598 10.443359 2.2773438 z " /><path
d="m 6,5 c 0,-2.757 2.243,-5 5,-5 2.757,0 5,2.243 5,5 V 5.5 C 16,5.776 15.776,6 15.5,6 15.224,6 15,5.776 15,5.5 V 5 C 15,2.794 13.206,1 11,1 8.794,1 7,2.794 7,5 7,6.86 8.277,8.428 10,8.873 V 7 L 13,9.5 10,12 V 9.899 C 7.721,9.434 6,7.414 6,5 Z"
id="path3" /></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg3"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs3" /><path
d="M5 12v-12h-2v12h-2.5l3.5 3.5 3.5-3.5h-2.5z"
id="path1" /><path
d="M 14.334849,4.1517112 H 11.883382 V 1.785868 c 0,-0.1187227 -0.09983,-0.2150766 -0.222859,-0.2150766 h -1.337165 c -0.12302,0 -0.222861,0.096353 -0.222861,0.2150766 V 4.1517112 H 7.6490291 c -0.1230181,0 -0.2228598,0.096353 -0.2228598,0.2150768 v 1.2904597 c 0,0.1187229 0.099841,0.2150767 0.2228598,0.2150767 h 2.4514679 v 2.365843 c 0,0.1187227 0.09983,0.2150768 0.222861,0.2150768 h 1.337165 c 0.123019,0 0.222859,-0.096353 0.222859,-0.2150768 v -2.365843 h 2.451467 c 0.12302,0 0.22286,-0.096355 0.22286,-0.2150767 V 4.366788 c 0,-0.1187229 -0.09983,-0.2150768 -0.22286,-0.2150768 z"
id="path1-3"
style="stroke-width:0.437868" /></svg>

After

Width:  |  Height:  |  Size: 1010 B

+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg3"
sodipodi:docname="sort-heart.svg"
xml:space="preserve"
inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs3" /><sodipodi:namedview
id="namedview3"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="26.077075"
inkscape:cx="4.0265253"
inkscape:cy="4.640091"
inkscape:window-width="1920"
inkscape:window-height="1020"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg3"
showguides="true" /><path
d="M5 12v-12h-2v12h-2.5l3.5 3.5 3.5-3.5h-2.5z"
id="path1" /><path
d="M 13.78723,0 C 12.941692,0 12.207573,0.47431375 11.834786,1.1709458 11.461999,0.47431375 10.72788,0 9.8823418,0 c -1.2219697,0 -2.21277,0.99080032 -2.21277,2.2127699 0,2.9937477 4.1652142,5.0763547 4.1652142,5.0763547 0,0 4.165214,-2.082607 4.165214,-5.0763547 C 16,0.99080032 15.0092,0 13.78723,0 Z"
id="path1-5"
style="stroke-width:0.520651" /></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+1 -1
Submodule common updated: ec0812ad9d...7df69021ea
+20 -8
View File
@@ -16,6 +16,18 @@ import Pagination from '#/components/pagination/pagination.vue';
import { get } from '#/src/api.js';
import events from '#/src/events.js';
import navigate from '#/src/navigate.js';
import { formatRange, parseLetterRange, parseRange } from '#/utils/parse-range.js';
// sliders need both ends, fill open ends with the slider limits
function getSliderRange(rangeString, [defaultMin, defaultMax], parse = parseRange) {
const range = parse(rangeString);
return [range?.min ?? defaultMin, range?.max ?? defaultMax];
}
function formatSliderRange([min, max]) {
return formatRange({ min, max });
}
const pageContext = inject('pageContext');
const { pageProps, urlParsed, routeParams } = pageContext;
@@ -35,18 +47,18 @@ const order = ref(routeParams.order || urlParsed.search.order || 'likes.desc');
const filters = ref({
gender: urlParsed.search.gender,
ageRequired: !!urlParsed.search.age,
age: urlParsed.search.age?.split(',').map((age) => Number(age)) || [18, 100],
age: getSliderRange(urlParsed.search.age, [18, 100]),
dobRequired: !!urlParsed.search.dob,
dobType: urlParsed.search.dobt ? ({ bd: 'birthday', dob: 'dob' })[urlParsed.search.dobt] : 'birthday',
dob: urlParsed.search.dob || format(subYears(new Date(), 21), 'yyyy-MM-dd'),
country: urlParsed.search.c,
braSizeRequired: !!urlParsed.search.cup,
braSize: urlParsed.search.cup?.split(',') || ['A', 'Z'],
braSize: getSliderRange(urlParsed.search.cup, ['A', 'Z'], parseLetterRange),
naturalBoobs: urlParsed.search.nb ? urlParsed.search.nb === 'true' : undefined,
heightRequired: !!urlParsed.search.height,
height: urlParsed.search.height?.split(',').map((height) => Number(height)) || [50, 220],
height: getSliderRange(urlParsed.search.height, [50, 220]),
weightRequired: !!urlParsed.search.weight,
weight: urlParsed.search.weight?.split(',').map((weight) => Number(weight)) || [30, 200],
weight: getSliderRange(urlParsed.search.weight, [30, 200]),
avatarRequired: !!urlParsed.search.avatar,
});
@@ -85,14 +97,14 @@ async function search(options = {}) {
q: q.value || undefined,
order: order.value,
gender: filters.value.gender || undefined,
age: filters.value.ageRequired ? filters.value.age.join(',') : undefined,
age: filters.value.ageRequired ? formatSliderRange(filters.value.age) : undefined,
dob: filters.value.dobRequired ? filters.value.dob : undefined,
dobt: filters.value.dobRequired ? ({ birthday: 'bd', dob: 'dob' })[filters.value.dobType] : undefined,
cup: filters.value.braSizeRequired ? filters.value.braSize.join(',') : undefined,
cup: filters.value.braSizeRequired ? formatSliderRange(filters.value.braSize) : undefined,
c: filters.value.country || undefined,
nb: filters.value.naturalBoobs,
height: filters.value.heightRequired ? filters.value.height.join(',') : undefined,
weight: filters.value.weightRequired ? filters.value.weight.join(',') : undefined,
height: filters.value.heightRequired ? formatSliderRange(filters.value.height) : undefined,
weight: filters.value.weightRequired ? formatSliderRange(filters.value.weight) : undefined,
avatar: filters.value.avatarRequired || undefined,
stashId: pageStash?.id,
};
+18 -7
View File
@@ -135,13 +135,18 @@ const aliases = Object
<dfn class="bio-label"><Icon icon="cake" />Date of birth</dfn>
<span class="birthdate">
<span class="birthdate-long">{{ formatDate(actor.dateOfBirth, actor.dateOfBirth.getFullYear() > 1 ? 'MMMM d, yyyy' : 'MMMM d') }}</span>
<span class="birthdate-short">{{ formatDate(actor.dateOfBirth, actor.dateOfBirth.getFullYear() > 1 ? 'MMM d, yyyy' : 'MMM d') }}</span>
<template v-if="actor.dateOfBirthPrecision === 'day'">
<span class="birthdate-long">{{ formatDate(actor.dateOfBirth, actor.dateOfBirth.getFullYear() > 1 ? 'MMMM d, yyyy' : 'MMMM d') }}</span>
<span class="birthdate-short">{{ formatDate(actor.dateOfBirth, actor.dateOfBirth.getFullYear() > 1 ? 'MMM d, yyyy' : 'MMM d') }}</span>
</template>
<span v-else-if="actor.dateOfBirthPrecision === 'month'">{{ formatDate(actor.dateOfBirth, 'MMMM, yyyy') }}</span>
<span v-else-if="actor.dateOfBirth.getFullYear() > 1">{{ formatDate(actor.dateOfBirth, 'yyyy') }}</span>
<span
v-if="!actor.dateOfDeath && actor.dateOfBirth.getFullYear() > 1"
class="age"
>{{ actor.ageFromBirth }}</span>
><template v-if="actor.ageFromBirthIsApproximate">~</template>{{ actor.ageFromBirth }}</span>
</span>
</li>
@@ -163,10 +168,16 @@ const aliases = Object
>
<dfn class="bio-label"><Icon icon="tombstone" />Date of death</dfn>
<span class="birthdate">{{ formatDate(actor.dateOfDeath, 'MMMM d, yyyy') }}<span
v-if="actor.ageAtDeath"
class="age"
>{{ actor.ageAtDeath }}</span></span>
<span class="birthdate">
<span v-if="actor.dateOfDeathPrecision === 'day'">{{ formatDate(actor.dateOfDeath, 'MMMM d, yyyy') }}</span>
<span v-else-if="actor.dateOfDeathPrecision === 'month'">{{ formatDate(actor.dateOfDeath, 'MMMM, yyyy') }}</span>
<span v-else>{{ formatDate(actor.dateOfDeath, 'yyyy') }}</span>
<span
v-if="actor.ageAtDeath"
class="age"
><template v-if="actor.ageAtDeathIsApproximate">~</template>{{ actor.ageAtDeath }}</span>
</span>
</li>
<li
+58
View File
@@ -1,4 +1,5 @@
<script setup>
import { nanoid } from 'nanoid';
import { ref, useId } from 'vue';
import { get } from '#/src/api.js';
@@ -9,7 +10,12 @@ defineProps({
type: Boolean,
default: false,
},
showUnknown: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['actor']);
const dropdownId = useId();
const actors = ref([]);
@@ -49,6 +55,23 @@ function focus() {
>
<ul class="actors nolist">
<li
v-if="showUnknown"
class="actor-unknown"
>
<span class="actor-label">Unidentified</span>
<Icon
v-for="gender in ['male', 'female', 'transsexual', null]"
:key="`actor-unknown-${gender}`"
v-close-popper
:icon="gender || 'question5'"
class="actor-gender"
:class="{ [`actor-${gender || 'other'}`]: true }"
@click="emit('actor', { name: gender ? `Unknown ${gender}` : 'Unknown', gender, isUnknown: true, id: `${gender || 'other'}_${nanoid()}` })"
/>
</li>
<li
v-for="actor in actors"
:key="`actor-${actor.slug}`"
@@ -89,6 +112,41 @@ function focus() {
}
}
.actor-unknown {
display: flex;
align-items: center;
.actor-label {
padding: .25rem .5rem;
flex-grow: 1;
}
}
.actor-gender {
padding: .5rem .5rem;
&:hover {
background: var(--glass-weak-50);
cursor: pointer;
}
}
.actor-male {
fill: var(--male);
}
.actor-female {
fill: var(--female);
}
.actor-transsexual {
fill: var(--trans);
}
.actor-other {
fill: var(--glass);
}
.avatar {
position: fixed;
display: none;
+11 -1
View File
@@ -33,7 +33,7 @@ const aliasTooltipId = useId();
>
<div class="avatar-container">
<Link
:href="`/actor/${actor.id}/${actor.slug}`"
:href="actor.isUnknown ? null : `/actor/${actor.id}/${actor.slug}`"
class="avatar-link no-link"
>
<img
@@ -101,10 +101,16 @@ const aliasTooltipId = useId();
<span class="label">
<span
v-if="actor.name"
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>
<span
v-else
class="name unknown"
>Unknown {{ actor.gender }}</span>
<img
v-if="actor.entity"
v-tooltip="{ content: actor.entity.name, ariaId: entityTooltipId }"
@@ -179,6 +185,10 @@ const aliasTooltipId = useId();
.name {
padding: 0 .25rem 0 .5rem;
&.unknown {
font-weight: normal;
}
}
.favicon {
+10 -2
View File
@@ -46,9 +46,12 @@ watch(() => props.scene, () => {
v-for="actor in [...item.value, ...newActors]"
:key="`actor-${actor.id}`"
class="actor"
:class="{ deleted: edits.actors && !edits.actors.some((actorId) => actorId === actor.id) }"
:class="{
deleted: edits.actors && !edits.actors.some((actorId) => actorId === actor.id),
unknown: actor.isUnknown,
}"
>
<span class="actor-name">{{ actor.name }}</span>
<span class="actor-name">{{ actor.name || ['Unknown', actor.gender].filter(Boolean).join(' ') }}</span>
<Icon
v-if="edits.actors && !edits.actors.some((actorId) => actorId === actor.id)"
@@ -68,6 +71,7 @@ watch(() => props.scene, () => {
<li class="new">
<ActorSearch
:disabled="!editing.has(item.key)"
:show-unknown="true"
@actor="addActor"
>
<Icon
@@ -131,6 +135,10 @@ watch(() => props.scene, () => {
color: var(--glass);
text-decoration: line-through;
}
&.unknown {
color: var(--glass-strong-10);
}
}
.actor,
+52 -8
View File
@@ -5,8 +5,10 @@ import { computed, inject, ref } from 'vue';
import Avatar from '#/components/edit/avatar.vue';
import Socials from '#/components/edit/revision-socials.vue';
import Checkbox from '#/components/form/checkbox.vue';
import Pagination from '#/components/pagination/pagination.vue';
import { get, post } from '#/src/api.js';
import navigate from '#/src/navigate.js';
import { formatDuration } from '#/utils/format.js';
defineProps({
@@ -31,10 +33,25 @@ const moviesById = computed(() => Object.fromEntries(movies.value.map((movie) =>
const avatarsById = computed(() => Object.fromEntries(avatars.value.map((avatar) => [avatar.id, avatar])));
const feedbacks = ref({});
const showReviewed = ref(false);
const showReviewed = ref(Object.hasOwn(pageContext.urlParsed.search, 'final'));
const reviewedRevisions = ref(new Set());
const expanded = ref(new Set());
const total = ref(pageContext.pageProps.revisionTotal);
const page = Number(pageContext.routeParams.page) || 1;
const limit = Number(pageContext.urlParsed.search.limit) || 100;
function getUnknownName(itemId) {
// unidentified actors are stored as gender_id
if (typeof itemId !== 'string') {
return null;
}
const gender = itemId.match(/^(male|female|transsexual)_/)?.[1];
return ['Unknown', gender].filter(Boolean).join(' ');
}
const mappedKeys = {
actors: actorsById,
// tags: tagsById,
@@ -58,7 +75,7 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
if (Array.isArray(value) && mappedKeys[key]) {
return [key, value.map((itemId) => ({
id: itemId,
name: mappedKeys[key].value[itemId]?.name || mappedKeys[key].value[itemId]?.title,
name: mappedKeys[key].value[itemId]?.name || mappedKeys[key].value[itemId]?.title || getUnknownName(itemId),
modified: revision.deltas.some((delta) => delta.key === key && !delta.value.some((deltaItemId) => deltaItemId === itemId)),
}))];
}
@@ -98,7 +115,7 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
...delta,
value: delta.value.map((itemId) => ({
id: itemId,
name: mappedKeys[delta.key].value[itemId]?.name || mappedKeys[delta.key].value[itemId]?.title,
name: mappedKeys[delta.key].value[itemId]?.name || mappedKeys[delta.key].value[itemId]?.title || getUnknownName(itemId),
modified: !revision.base[delta.key].includes(itemId),
})),
};
@@ -163,7 +180,8 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
async function reloadRevisions() {
const updatedRevisions = await get(`/revisions/${domain}`, {
isFinalized: showReviewed.value ? undefined : false,
limit: 50,
page,
limit,
});
actors.value = updatedRevisions.actors;
@@ -171,6 +189,14 @@ async function reloadRevisions() {
movies.value = updatedRevisions.movies;
avatars.value = updatedRevisions.avatars;
revisions.value = updatedRevisions.revisions;
total.value = updatedRevisions.total;
navigate(pageContext.urlParsed.pathname, {
...pageContext.urlParsed.search,
final: showReviewed.value || undefined,
}, {
redirect: false,
});
}
async function reviewRevision(revision, isApproved) {
@@ -208,10 +234,15 @@ async function banEditor(revision) {
<template>
<div class="page">
<div
v-if="context === 'admin'"
class="revs-header"
>
<span
v-if="typeof total === 'number'"
class="revs-total"
>{{ total }} revisions</span>
<Checkbox
v-if="context === 'admin'"
label="Show finalized"
:checked="showReviewed"
@change="(checked) => { showReviewed = checked; reloadRevisions(); }"
@@ -388,13 +419,12 @@ async function banEditor(revision) {
class="rev-compact"
@click="expanded.add(rev.id)"
>
<span class="rev-scene nolink noshrink"><template v-if="context !== 'scene' && context !== 'actor'">{{ rev.sceneId || rev.actorId }}</template>@{{ rev.hash.slice(0, 6) }}</span>
<span
v-if="context !== 'scene'"
class="rev-title nolink ellipsis"
>{{ rev.base.title }}</span>
>{{ rev.base.title || rev.base.name }}</span>
<span class="rev-summary">
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
@@ -431,6 +461,13 @@ async function banEditor(revision) {
</div>
</li>
</ul>
<Pagination
v-if="total"
:total="total"
:page="page"
:limit="limit"
/>
</div>
</template>
@@ -443,13 +480,20 @@ async function banEditor(revision) {
.revs-header {
display: flex;
margin-bottom: 1rem;
justify-content: space-between;
box-sizing: border-box;
padding: .5rem .5rem .75rem .5rem;
width: 100%;
.check-container {
display: inline-flex;
}
}
.revs-total {
color: var(--glass-strong-10);
}
.revs {
width: 100%;
flex-grow: 1;
+1 -1
View File
@@ -166,7 +166,7 @@ watch(() => props.scene, () => {
.tags-sections {
display: flex;
flex-direction: column;
gap: .75rem;
gap: 1.5rem;
margin: .5rem 0;
}
+44 -12
View File
@@ -1,7 +1,7 @@
<script setup>
import { ref } from 'vue';
import { computed, ref } from 'vue';
defineProps({
const props = defineProps({
results: {
type: Number,
default: null,
@@ -10,25 +10,47 @@ defineProps({
type: Boolean,
default: false,
},
// pages with their own filters toggle control the sidebar with these, otherwise it keeps its own state and toggle
showFull: {
type: Boolean,
default: null,
},
showCompact: {
type: Boolean,
default: null,
},
});
const emit = defineEmits(['close']);
// desktop defaults to open, compact defaults to closed
// we can't measure viewframe in SSR, so use separate toggles
const showFilters = ref(true);
const showFiltersCompact = ref(false);
const ownShowFull = ref(true);
const ownShowCompact = ref(false);
const isControlled = computed(() => props.showFull !== null || props.showCompact !== null);
const showFull = computed(() => (isControlled.value ? !!props.showFull : ownShowFull.value));
const showCompact = computed(() => (isControlled.value ? !!props.showCompact : ownShowCompact.value));
function toggleFilters(state) {
showFilters.value = state ?? !showFilters.value;
showFiltersCompact.value = state ?? !showFiltersCompact.value;
if (isControlled.value) {
if (state === false) {
emit('close');
}
return;
}
ownShowFull.value = state ?? !ownShowFull.value;
ownShowCompact.value = state ?? !ownShowCompact.value;
}
</script>
<template>
<div class="filters-frame">
<div
v-show="showFilters"
class="filters-container"
:class="{ show: showFiltersCompact }"
:class="{ 'show-full': showFull, 'show-compact': showCompact }"
@click="toggleFilters(false)"
>
<div class="filters-sidebar">
@@ -47,9 +69,10 @@ function toggleFilters(state) {
>Show {{ results }} {{ results > 1 ? 'results' : 'result' }}</button>
</div>
<!-- in full mode, pages with their own toggle close the sidebar with that, compact mode still needs a way out of the overlay -->
<div
class="filters-toggle close"
:class="{ 'show-full': showFilters, 'show-compact': showFiltersCompact }"
:class="{ 'show-full': showFull && !isControlled, 'show-compact': showCompact }"
@click.stop="toggleFilters(false)"
>
<Icon
@@ -65,8 +88,9 @@ function toggleFilters(state) {
</div>
<div
v-if="!isControlled"
class="filters-toggle open"
:class="{ 'show-full': !showFilters, 'show-compact': !showFiltersCompact }"
:class="{ 'show-full': !showFull, 'show-compact': !showCompact }"
@click.stop="toggleFilters(true)"
><Icon icon="filter" /></div>
</div>
@@ -359,8 +383,12 @@ function toggleFilters(state) {
}
.filters-container {
display: flex;
display: none;
height: 100%;
&.show-full {
display: flex;
}
}
.filters-sidebar {
@@ -450,7 +478,11 @@ function toggleFilters(state) {
z-index: 500;
background: var(--background-dim);
&.show {
&.show-full {
display: none;
}
&.show-compact {
display: flex;
}
}
+149
View File
@@ -0,0 +1,149 @@
<script setup>
import {
computed,
ref,
} from 'vue';
import Range from '#/components/form/range.vue';
const props = defineProps({
filters: {
type: Object,
default: null,
},
counts: {
type: Object,
default: null,
},
});
const emit = defineEmits(['update']);
// beyond this the slider loses too much fidelity for the common small counts, the last step means 'or more'
const sliderCap = 10;
const rows = [
{ key: 'group', label: 'Actors', icon: 'users' },
{ key: 'females', label: 'Females', icon: 'female' },
{ key: 'males', label: 'Males', icon: 'male' },
{ key: 'trans', label: 'Trans', icon: 'transsexual' },
];
// values while dragging, before the change is committed and the scenes reload
const dragging = ref({});
const sliders = computed(() => rows.map((row) => {
const filter = props.filters[row.key];
const buckets = props.counts?.[row.key] || [];
const countMax = buckets.at(-1)?.value ?? sliderCap; // buckets are sorted by value
// at least 1 to keep the slider usable, and never below the active filter so its handles stay in view
const max = Math.max(1, Math.min(countMax, sliderCap), filter?.min ?? 0, filter?.max ?? 0);
const value = [filter?.min ?? 0, filter?.max ?? max];
return {
...row,
max,
isCapped: countMax > max,
value,
display: dragging.value[row.key] || value,
mountKey: `${row.key}-${max}-${value.join('-')}`, // remount when the range or filter changes, the slider only reads its value on mount
};
}));
function getEndLabel(slider, value) {
return value === slider.max && slider.isCapped ? `${value}+` : value;
}
function updateRange(slider, [min, max], reload) {
if (!reload) {
dragging.value[slider.key] = [min, max];
return;
}
delete dragging.value[slider.key];
// the top of the slider means 'or more', the full range means no filter
const range = {
min,
max: max === slider.max ? null : max,
};
emit('update', slider.key, min === 0 && range.max === null ? null : range, true);
}
</script>
<template>
<div class="filter groups-container">
<div
v-for="slider in sliders"
:key="slider.key"
class="filter-row"
:title="slider.label"
>
<Icon
:icon="slider.icon"
:class="`gender-${slider.key}`"
/>
<Range
:key="slider.mountKey"
:min="0"
:max="slider.max"
:value="slider.value"
:allow-enable="false"
@input="(range) => updateRange(slider, range, false)"
@change="(range) => updateRange(slider, range, true)"
>
<template #start><span class="range-label">{{ slider.display[0] }}</span></template>
<template #end><span class="range-label">{{ getEndLabel(slider, slider.display[1]) }}</span></template>
</Range>
</div>
</div>
</template>
<style scoped>
.groups-container {
display: flex;
flex-direction: column;
gap: .5rem 0;
}
.filter-row {
display: flex;
align-items: center;
gap: 0 .25rem;
.range-container {
flex-grow: 1;
}
}
.range-label {
display: inline-block;
min-width: 1.5rem;
color: var(--glass-strong-10);
font-size: .9rem;
font-weight: bold;
text-align: center;
}
.range-container {
padding: .25rem 0;
}
.icon {
fill: var(--glass);
}
.gender-females {
fill: var(--female);
}
.gender-males {
fill: var(--male);
}
.gender-trans {
fill: var(--trans);
}
</style>
+117 -27
View File
@@ -1,50 +1,140 @@
<script setup>
defineProps({
// desktop and compact have separate open states, because we can't measure the viewport in SSR
showFull: {
type: Boolean,
default: true,
},
showCompact: {
type: Boolean,
default: false,
},
count: {
type: Number,
default: 0,
},
});
const emit = defineEmits(['toggle']);
</script>
<template>
<div
class="filters-toggle open"
@click.stop="emit('toggle')"
><Icon icon="filter" /></div>
<button
type="button"
class="filter-toggle nobutton"
:class="{
'open-full': showFull,
'open-compact': showCompact,
'active': count > 0,
}"
@click="emit('toggle')"
>
<!-- the media query picks the open state of the current viewport, matching the sidebar's own breakpoint -->
<Icon
icon="arrow-left2"
class="toggle-close"
/>
<Icon
icon="filter"
class="toggle-open"
/>
<!-- not filter-count, the filters sidebar has a global style by that name -->
<span
v-if="count > 0"
class="toggle-count"
>{{ count }}</span>
</button>
</template>
<style scoped>
.filters-toggle {
min-width: 2.75rem;
height: 3rem;
justify-content: center;
.filter-toggle {
display: flex;
align-items: center;
padding: 0 .25rem;
border-radius: 0 .5rem .5rem 0;
background: var(--background);
color: var(--glass);
gap: .75rem;
padding: 0 1rem;
border-radius: 0 .25rem .25rem 0;
margin-right: 1rem;
font-weight: bold;
box-shadow: inset 0 0 3px var(--shadow-weak-30);
&.open {
left: 0;
right: auto;
}
&.show-full {
display: flex;
}
&.close .cross {
display: none;
}
color: var(--glass-strong-10);
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
.icon {
fill: var(--glass);
fill: var(--glass-strong-10);
margin: .75rem 0 .75rem 0;
}
&.active {
padding-right: .75rem;
}
&:hover {
color: var(--primary);
cursor: pointer;
box-shadow: 0 0 3px var(--shadow-weak-20);
.icon {
fill: var(--primary);
}
}
.toggle-close {
display: none;
}
&.open-full {
.toggle-close {
display: inline-block;
}
.toggle-open {
display: none;
}
}
}
.toggle-count {
min-width: 1.25rem;
height: 1.25rem;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: 0 .25rem;
border-radius: .625rem;
background: var(--primary);
color: var(--text-light);
font-size: .8rem;
font-weight: bold;
line-height: 1;
}
@media (--compact) {
.filter-toggle {
/* the full mode state doesn't apply in compact mode, matches the specificity of the open-full rule to override it */
&,
&.open-full {
.toggle-close {
display: none;
}
.toggle-open {
display: inline-block;
}
}
/* after the reset, so it wins when both states are open */
&.open-compact {
.toggle-close {
display: inline-block;
}
.toggle-open {
display: none;
}
}
}
}
</style>
+86 -57
View File
@@ -1,5 +1,7 @@
<script setup>
import { ref } from 'vue';
import { computed, ref } from 'vue';
import Range from '#/components/form/range.vue';
const props = defineProps({
filters: {
@@ -13,36 +15,86 @@ const props = defineProps({
});
const emit = defineEmits(['update']);
const selected = ref(props.filters.years);
function updateYears() {
emit('update', 'years', selected.value);
// values while dragging, before the change is committed and the scenes reload
const dragging = ref(null);
const slider = computed(() => {
const aggYears = (props.years || []).map((year) => year.year);
const currentYear = new Date().getFullYear();
const min = aggYears.length > 0 ? Math.min(...aggYears) : currentYear - 1;
const max = Math.max(aggYears.length > 0 ? Math.max(...aggYears) : currentYear, min + 1); // keep at least one step
const range = props.filters.yearRange;
const list = props.filters.years || [];
// a year list from an older link is shown as the span it covers
const value = list.length > 0
? [Math.min(...list), Math.max(...list)]
: [range?.min ?? min, range?.max ?? max];
return {
min,
max,
value,
positions: [flipYear(value[1], min, max), flipYear(value[0], min, max)],
display: dragging.value || value,
isFiltered: !!range || list.length > 0,
mountKey: `${min}-${max}-${value.join('-')}`, // remount when the bounds or filter change, the slider only reads its value on mount
};
});
// the slider runs from newest on the left to oldest on the right, by mirroring the years onto the ascending slider positions
// the same function converts both ways: years to positions and positions to years
function flipYear(yearOrPosition, min, max) {
return min + max - yearOrPosition;
}
function clearYears() {
selected.value = [];
emit('update', 'years', selected.value);
emit('update', 'years', [], false);
emit('update', 'yearRange', null, true);
}
function updateRange([positionA, positionB], reload) {
const min = flipYear(positionB, slider.value.min, slider.value.max);
const max = flipYear(positionA, slider.value.min, slider.value.max);
if (!reload) {
dragging.value = [min, max];
return;
}
dragging.value = null;
// ends at the slider limits are left open, so 'and later' keeps including new years, the full range means no filter
const range = {
min: min === slider.value.min ? null : min,
max: max === slider.value.max ? null : max,
};
emit('update', 'years', [], false); // replaces a year list from an older link
emit('update', 'yearRange', range.min === null && range.max === null ? null : range, true);
}
</script>
<template>
<div class="years-container">
<select
v-model="selected"
class="years nobar"
multiple
@change="updateYears"
>
<option
v-for="year in years"
:key="`year-${year.year}`"
class="year"
:value="year.year"
>{{ year.year }}</option>
</select>
<div class="years-filter">
<div class="years-range">
<Range
:key="slider.mountKey"
:min="slider.min"
:max="slider.max"
:value="slider.positions"
:allow-enable="false"
@input="(positions) => updateRange(positions, false)"
@change="(positions) => updateRange(positions, true)"
>
<template #start><span class="range-label">{{ slider.display[1] }}</span></template>
<template #end><span class="range-label">{{ slider.display[0] }}</span></template>
</Range>
</div>
<Icon
v-show="selected.length > 0"
v-show="slider.isFiltered"
icon="cross2"
class="clear"
@click="clearYears"
@@ -51,54 +103,22 @@ function clearYears() {
</template>
<style scoped>
.years-container {
.years-filter {
display: flex;
align-items: stretch;
border-bottom: solid 1px var(--glass-weak-30);
}
.years {
height: 2.5rem;
padding: .5rem;
.years-range {
padding: .25rem 0;
flex-grow: 1;
border: none;
overflow-x: auto;
overflow-y: hidden;
background: none;
color: var(--text);
&:focus .year:checked {
background: var(--primary) linear-gradient(0deg, var(--primary) 0%, var(--primary) 100%);
}
&:focus {
outline: none;
}
}
.year {
display: inline-block;
padding: .25rem;
color: var(--text);
font-size: .8rem;
&:hover {
color: var(--primary);
cursor: pointer;
}
&:checked {
color: var(--primary);
background: none;
font-weight: bold;
}
}
.clear {
height: auto;
display: flex;
align-items: center;
padding: 0 .5rem;
padding: 0 .5rem 0 0;
fill: var(--glass);
&:hover {
@@ -106,4 +126,13 @@ function clearYears() {
cursor: pointer;
}
}
.range-label {
display: inline-block;
min-width: 2.5rem;
color: var(--glass-strong-10);
font-size: .8rem;
font-weight: bold;
text-align: center;
}
</style>
+107 -8
View File
@@ -1,11 +1,13 @@
<script setup>
import { parse } from 'path-to-regexp';
import { inject, ref } from 'vue';
import { computed, inject, ref } from 'vue';
import Campaign from '#/components/campaigns/campaign.vue';
import ActorsFilter from '#/components/filters/actors.vue';
import ChannelsFilter from '#/components/filters/channels.vue';
import Filters from '#/components/filters/filters.vue';
import TagsFilter from '#/components/filters/tags.vue';
import FilterToggle from '#/components/filters/toggle.vue';
import YearsFilter from '#/components/filters/years.vue';
import Checkbox from '#/components/form/checkbox.vue';
@@ -15,9 +17,15 @@ import { get } from '#/src/api.js';
import events from '#/src/events.js';
import navigate from '#/src/navigate.js';
import { getActorIdentifier, parseActorIdentifier } from '#/src/query.js';
import { formatYears, parseYears } from '#/utils/parse-range.js';
const pageContext = inject('pageContext');
const { pageProps, routeParams, urlParsed } = pageContext;
const {
pageProps,
routeParams,
urlParsed,
campaigns,
} = pageContext;
const {
actor: pageActor,
@@ -39,6 +47,11 @@ const loading = ref(false);
const showFilters = ref(true);
// desktop defaults to open, compact defaults to closed
// we can't measure the viewport in SSR, so use separate toggles, each viewport only reads its own
const showFiltersFull = ref(true);
const showFiltersCompact = ref(false);
const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || [];
const queryActors = actorIds.map((urlActorId) => aggActors.value.find((aggActor) => aggActor.id === urlActorId)).filter(Boolean);
@@ -49,13 +62,27 @@ const queryEntity = networks[urlParsed.search.e] || channels[urlParsed.search.e]
const filters = ref({
search: urlParsed.search.q,
years: urlParsed.search.years?.split(',').map((year) => Number(year)).filter(Boolean) || [],
...parseYears(urlParsed.search.years),
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
entity: queryEntity,
actors: queryActors,
requireCover: !!urlParsed.search.cover,
});
// the search input updates the filter while typing, only count the search once it's applied
const appliedSearch = ref(urlParsed.search.q);
// indicates the results are narrowed down: the search, each tag, actor and the channel count individually, the year range and cover requirement count once
// the page's own actor, tag or channel aren't in these filters, so they aren't counted
const filterCount = computed(() => [
appliedSearch.value?.trim() ? 1 : 0,
filters.value.tags.length,
filters.value.actors.length,
filters.value.entity ? 1 : 0,
filters.value.years.length > 0 || filters.value.yearRange ? 1 : 0,
filters.value.requireCover ? 1 : 0,
].reduce((acc, count) => acc + count, 0));
function getPath(targetScope, preserveQuery) {
const path = parse(routeParams.path).map((segment) => {
if (segment.name === 'scope') {
@@ -77,6 +104,8 @@ function getPath(targetScope, preserveQuery) {
}
async function search(options = {}) {
appliedSearch.value = filters.value.search;
if (options.resetPage !== false) {
currentPage.value = 1;
}
@@ -103,7 +132,7 @@ async function search(options = {}) {
navigate(getPath(scope.value, false), {
...query,
years: filters.value.years.join(',') || undefined,
years: formatYears(filters.value),
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,
e: filters.value.entity?.type === 'network' ? `_${filters.value.entity.slug}` : (filters.value.entity?.slug || undefined),
@@ -111,7 +140,7 @@ async function search(options = {}) {
const res = await get('/movies', {
...query,
years: filters.value.years.filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
years: formatYears(filters.value),
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(','),
e: entitySlug,
@@ -132,6 +161,11 @@ async function search(options = {}) {
events.emit('scrollUp');
}
function toggleFilters(state) {
showFiltersFull.value = state ?? !showFiltersFull.value;
showFiltersCompact.value = state ?? !showFiltersCompact.value;
}
function updateFilter(prop, value, reload = true) {
filters.value[prop] = value;
@@ -146,6 +180,9 @@ function updateFilter(prop, value, reload = true) {
<Filters
v-if="showFilters"
:class="{ loading }"
:show-full="showFiltersFull"
:show-compact="showFiltersCompact"
@close="toggleFilters(false)"
>
<div class="filter search-container">
<!-- onsearch not compatible with FF and Safari -->
@@ -205,8 +242,30 @@ function updateFilter(prop, value, reload = true) {
</Filters>
<div class="movies-container">
<Campaign
v-if="campaigns?.meta"
:campaign="campaigns.meta"
class="campaign-meta campaign-full"
/>
<div class="movies-header">
<div class="meta">{{ total }} results</div>
<span class="header-filter">
<FilterToggle
v-if="showFilters"
:show-full="showFiltersFull"
:show-compact="showFiltersCompact"
:count="filterCount"
@toggle="toggleFilters()"
/>
<div class="meta">{{ total }}<span class="meta-label">&nbsp;results</span></div>
</span>
<Campaign
v-if="campaigns?.meta"
:campaign="campaigns.meta"
class="campaign-meta campaign-gap"
/>
<select
v-model="scope"
@@ -264,16 +323,42 @@ function updateFilter(prop, value, reload = true) {
}
.movies-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: .5rem 1rem .5rem 0;
.campaign {
max-height: 6rem;
justify-content: center;
margin: 0 1rem;
}
}
.header-filter {
display: flex;
align-items: center;
padding: .5rem 1rem .25rem 4rem;
flex-shrink: 0;
}
.meta {
display: flex;
flex-grow: 1;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
margin-top: 2px;
}
:deep(.campaign-meta) .campaign-banner {
width: auto;
}
.campaign-full {
height: auto;
}
.campaign-full {
display: none;
}
.movies {
@@ -289,6 +374,16 @@ function updateFilter(prop, value, reload = true) {
}
}
@media(--small-10) {
.campaign-gap {
display: none;
}
.campaign-full {
display: flex;
}
}
@media(--small-20) {
.movies {
padding: .5rem .5rem 1rem .5rem;
@@ -300,5 +395,9 @@ function updateFilter(prop, value, reload = true) {
.movies {
grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}
.meta-label {
display: none;
}
}
</style>
+4
View File
@@ -13,6 +13,10 @@ const props = defineProps({
type: Number,
default: null,
},
limit: {
type: Number,
default: null,
},
redirect: {
type: Boolean,
default: true,
+102 -8
View File
@@ -12,8 +12,10 @@ import Campaign from '#/components/campaigns/campaign.vue';
import ActorsFilter from '#/components/filters/actors.vue';
import ChannelsFilter from '#/components/filters/channels.vue';
import Filters from '#/components/filters/filters.vue';
import GroupsFilter from '#/components/filters/groups.vue';
import TagsFilter from '#/components/filters/tags.vue';
import FilterToggle from '#/components/filters/toggle.vue';
import YearsFilter from '#/components/filters/years.vue';
import Ellipsis from '#/components/loading/ellipsis.vue';
import Pagination from '#/components/pagination/pagination.vue';
@@ -23,6 +25,7 @@ import { get } from '#/src/api.js';
import entityPrefixes from '#/src/entities-prefixes.js';
import navigate from '#/src/navigate.js';
import { getActorIdentifier, parseActorIdentifier } from '#/src/query.js';
import { formatRange, formatYears, parseRange, parseYears } from '#/utils/parse-range.js';
const props = defineProps({
showFilters: {
@@ -64,6 +67,7 @@ const aggActors = ref(pageProps.aggActors || []);
const aggTags = ref(pageProps.aggTags || []);
const aggActorTags = ref(pageProps.aggActorTags || []);
const aggChannels = ref(pageProps.aggChannels || []);
const aggActorCounts = ref(pageProps.aggActorCounts || null);
const currentPage = ref(Number(routeParams.page));
const scope = ref(routeParams.scope || props.defaultScope);
@@ -71,6 +75,11 @@ const total = ref(Number(pageProps.sceneTotal || pageProps.total));
const loading = ref(false);
const scenesContainer = ref(null);
// desktop defaults to open, compact defaults to closed
// we can't measure the viewport in SSR, so use separate toggles, each viewport only reads its own
const showFiltersFull = ref(true);
const showFiltersCompact = ref(false);
const view = ref(env.scenesView || 'grid');
const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || [];
@@ -83,13 +92,31 @@ const queryEntity = networks[urlParsed.search.e] || channels[urlParsed.search.e]
const filters = ref({
search: urlParsed.search.q,
years: urlParsed.search.years?.split(',').filter(Boolean).map(Number) || [],
...parseYears(urlParsed.search.years),
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
onlyActorTags: Object.hasOwn(urlParsed.search, 'at'),
entity: queryEntity,
actors: queryActors,
group: parseRange(urlParsed.search.group),
females: parseRange(urlParsed.search.females),
males: parseRange(urlParsed.search.males),
trans: parseRange(urlParsed.search.trans),
});
// the search input updates the filter while typing, only count the search once it's applied
const appliedSearch = ref(urlParsed.search.q);
// indicates the results are narrowed down: the search, each tag, actor and the channel count individually, each range counts once
// the page's own actor, tag or channel aren't in these filters, so they aren't counted
const filterCount = computed(() => [
appliedSearch.value?.trim() ? 1 : 0,
filters.value.tags.length,
filters.value.actors.length,
filters.value.entity ? 1 : 0,
filters.value.years.length > 0 || filters.value.yearRange ? 1 : 0,
...['group', 'females', 'males', 'trans'].map((key) => (filters.value[key] ? 1 : 0)),
].reduce((acc, count) => acc + count, 0));
const sceneCampaign = campaigns?.scenes;
const campaignIndex = campaigns?.index;
@@ -116,6 +143,8 @@ function getPath(targetScope, preserveQuery) {
}
async function search(options = {}) {
appliedSearch.value = filters.value.search;
if (options.resetPage !== false) {
currentPage.value = 1;
}
@@ -132,6 +161,10 @@ async function search(options = {}) {
const query = {
q: filters.value.search || undefined,
group: formatRange(filters.value.group),
females: formatRange(filters.value.females),
males: formatRange(filters.value.males),
trans: formatRange(filters.value.trans),
};
const entity = filters.value.entity || pageEntity;
@@ -142,7 +175,7 @@ async function search(options = {}) {
navigate(getPath(scope.value, false), {
...query,
years: filters.value.years.join(',') || undefined,
years: formatYears(filters.value),
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,
@@ -152,7 +185,7 @@ async function search(options = {}) {
const res = await get('/scenes', {
...query,
years: filters.value.years.filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
years: formatYears(filters.value),
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,
@@ -168,6 +201,7 @@ async function search(options = {}) {
aggTags.value = res.aggTags;
aggActorTags.value = res.aggActorTags;
aggChannels.value = res.aggChannels;
aggActorCounts.value = res.aggActorCounts;
total.value = res.total;
loading.value = false;
@@ -184,6 +218,11 @@ function updateFilter(prop, value, reload = true) {
}
}
function toggleFilters(state) {
showFiltersFull.value = state ?? !showFiltersFull.value;
showFiltersCompact.value = state ?? !showFiltersCompact.value;
}
function setView(newView) {
view.value = newView;
Cookies.set('scenesView', newView);
@@ -199,6 +238,9 @@ function setView(newView) {
<Filters
v-if="showFilters"
:loading="loading"
:show-full="showFiltersFull"
:show-compact="showFiltersCompact"
@close="toggleFilters(false)"
>
<div class="filter search-container">
<!-- onsearch not compatible with FF and Safari -->
@@ -248,6 +290,12 @@ function setView(newView) {
:actors="aggActors"
@update="updateFilter"
/>
<GroupsFilter
:filters="filters"
:counts="aggActorCounts"
@update="updateFilter"
/>
</Filters>
</transition>
@@ -256,16 +304,34 @@ function setView(newView) {
class="scenes-container"
:class="{ loading }"
>
<Campaign
v-if="campaigns?.meta"
:campaign="campaigns.meta"
class="campaign-meta campaign-full"
/>
<div
v-if="showMeta"
class="scenes-header"
>
<div class="meta">{{ total }} results</div>
<span class="header-filter">
<FilterToggle
v-if="showFilters"
:show-full="showFiltersFull"
:show-compact="showFiltersCompact"
:count="filterCount"
@toggle="toggleFilters()"
/>
<div
class="meta"
>{{ total }}<span class="meta-label">&nbsp;results</span></div>
</span>
<Campaign
v-if="campaigns?.meta"
:campaign="campaigns.meta"
class="campaign-meta"
class="campaign-meta campaign-gap"
/>
<div class="views">
@@ -412,12 +478,12 @@ function setView(newView) {
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: .5rem 1rem .25rem 4rem;
padding: .5rem 1rem .5rem 0;
.campaign {
max-height: 6rem;
justify-content: center;
margin: .5rem 1rem 0 1rem;
margin: 0 1rem;
/* makes empty area link to ad, bit too annoying
width: 0;
flex-grow: 1;
@@ -437,7 +503,13 @@ function setView(newView) {
justify-content: space-between;
align-items: center;
flex-shrink: 0;
margin-bottom: .5rem;
margin-top: 2px;
}
.header-filter {
display: flex;
align-items: center;
flex-shrink: 0;
}
.scenes-items {
@@ -458,6 +530,14 @@ function setView(newView) {
width: auto;
}
.campaign-full {
height: auto;
}
.campaign-full {
display: none;
}
.campaign-scene {
width: 100%;
aspect-ratio: 2 / 1; /* ensures banner can't be taller than scene tile */
@@ -561,6 +641,14 @@ function setView(newView) {
.scopes .views {
width: 100%;
}
.campaign-gap {
display: none;
}
.campaign-full {
display: flex;
}
}
@media(--small-20) {
@@ -582,4 +670,10 @@ function setView(newView) {
justify-content: flex-start;
}
}
@media(--small-50) {
.meta-label {
display: none;
}
}
</style>
+17 -3
View File
@@ -92,16 +92,23 @@ const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.id ===
<ul
class="row actors nolist"
:title="scene.actors.map((actor) => actor.name).join(', ')"
:title="scene.actors.map((actor) => actor.name || (actor.gender && `Unknown ${actor.gender}`) || 'Unknown').join(', ')"
>
<li
v-for="actor in scene.actors"
:key="`actor-${scene.id}-${actor.id}`"
class="actor"
:class="{ unknown: actor.isUnknown }"
>
<span
v-if="actor.isUnknown"
class="actor-name"
>{{ actor.gender ? `Unknown ${actor.gender}` : 'Unknown' }}</span>
<Link
v-else
:href="`/actor/${actor.id}/${actor.slug}`"
class="nolink"
class="actor-name nolink"
>{{ actor.name }}</Link>
</li>
</ul>
@@ -237,7 +244,7 @@ const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.id ===
color: var(--shadow);
}
.actor:hover,
.actor:not(.unknown):hover,
.tag:hover {
color: var(--primary);
}
@@ -255,6 +262,13 @@ const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.id ===
}
}
.actor.unknown {
.actor-name,
&:not(:last-child)::after {
color: var(--glass);
}
}
.tags {
height: 1.25rem;
overflow: hidden;
+18 -2
View File
@@ -10,7 +10,10 @@ defineProps({
</script>
<template>
<div class="serie-tile">
<div
class="serie-tile"
:class="{ noposter: !serie.poster }"
>
<a
v-if="serie.poster"
:href="`/serie/${serie.id}/${serie.slug}`"
@@ -39,8 +42,8 @@ defineProps({
flex-direction: column;
box-shadow: 0 0 3px var(--shadow-weak-30);
border-radius: .25rem;
overflow: hidden;
background: var(--background-base);
overflow: hidden;
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
@@ -53,6 +56,19 @@ defineProps({
&.unstashed {
opacity: .5;
}
&.noposter {
background: none;
box-shadow: none;
.title {
padding: 0;
&:hover {
color: var(--primary);
}
}
}
}
.poster-container {
+2
View File
@@ -261,6 +261,7 @@ async function reloadStashes(newStash) {
<StashMenu
:stashes="stashes"
:item-stashes="itemStashes"
:domain="domain"
@stash="(stash) => stashItem(stash)"
@unstash="(stash) => unstashItem(stash)"
@create="showStashDialog = true"
@@ -318,6 +319,7 @@ async function reloadStashes(newStash) {
<StashMenu
:stashes="stashes"
:item-stashes="itemStashes"
:domain="domain"
@stash="(stash) => stashItem(stash)"
@unstash="(stash) => unstashItem(stash)"
@create="showStashDialog = true"
+108 -12
View File
@@ -1,7 +1,9 @@
<script setup>
import { computed, ref } from 'vue';
import Checkbox from '#/components/form/checkbox.vue';
defineProps({
const props = defineProps({
stashes: {
type: Array,
default: () => [],
@@ -10,16 +12,64 @@ defineProps({
type: Array,
default: () => [],
},
domain: {
type: String,
default: 'scenes',
},
});
const emit = defineEmits(['stash', 'unstash', 'create']);
const sortings = ['used', 'name', 'size', 'created'];
const sorting = ref(localStorage.getItem('stashMenuSorting') || 'used');
const domainKey = {
actors: 'stashedActors',
scenes: 'stashedScenes',
movies: 'stashedMovies',
}[props.domain];
const sortedStashes = computed(() => props.stashes
.filter((stash) => !stash.isArchived)
.toSorted((stashA, stashB) => {
return stashA.createdAt - stashB.createdAt;
})
.toSorted((stashA, stashB) => {
if (sorting.value === 'used') {
return stashB.lastStashAt - stashA.lastStashAt;
}
if (sorting.value === 'name') {
return stashA.name.localeCompare(stashB.name);
}
if (sorting.value === 'size') {
return stashB[domainKey] - stashA[domainKey];
}
if (sorting.value === 'created') {
return stashA.createdAt - stashB.createdAt;
}
return 0;
}));
/*
.toSorted((stashA, stashB) => {
return stashB.isPrimary - stashA.isPrimary;
}));
*/
function toggleSorting() {
sorting.value = sortings[(sortings.indexOf(sorting.value) + 1) % sortings.length];
localStorage.setItem('stashMenuSorting', sorting.value);
}
</script>
<template>
<div class="stash-menu noselect">
<ul class="stash-list nolist noselect">
<li
v-for="userStash in stashes"
v-for="userStash in sortedStashes"
:key="`stash-${userStash.id}`"
class="menu-item"
>
@@ -32,13 +82,47 @@ const emit = defineEmits(['stash', 'unstash', 'create']);
</li>
</ul>
<div
v-close-popper
class="menu-item menu-stash create"
@click="emit('create')"
>
<Icon icon="plus3" />
New
<div class="menu-actions">
<div
v-close-popper
class="menu-item menu-stash menu-create"
@click="emit('create')"
>
<Icon icon="plus3" />
New
</div>
<Icon
v-if="sorting === 'used'"
v-tooltip="'By last stash'"
icon="sort-heart"
class="menu-sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'name'"
v-tooltip="'By name'"
icon="sort-alpha-asc"
class="menu-sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'size'"
v-tooltip="`By total stashed ${domain}`"
icon="sort-amount-desc"
class="menu-sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'created'"
v-tooltip="'By stash age'"
icon="sort-time-asc"
class="menu-sort"
@click="toggleSorting"
/>
</div>
</div>
</template>
@@ -85,10 +169,22 @@ const emit = defineEmits(['stash', 'unstash', 'create']);
.check-container {
margin-right: .5rem;
}
}
&.create {
flex-shrink: 0;
border-top: 1px solid var(--glass-weak-40);
.menu-actions {
flex-shrink: 0;
display: flex;
border-top: solid 1px var(--glass-weak-40);
}
.menu-sort {
padding: .75rem 1rem;
fill: var(--glass);
border-left: solid 1px var(--glass-weak-40);
&:hover {
fill: var(--primary);
cursor: pointer;
}
}
</style>
+121 -3
View File
@@ -1,5 +1,5 @@
<script setup>
import { inject, ref } from 'vue';
import { computed, inject, ref } from 'vue';
import StashDialog from '#/components/stashes/create.vue';
import StashTile from '#/components/stashes/tile.vue';
@@ -13,16 +13,55 @@ const stashes = ref(pageContext.pageProps.stashes);
const profile = ref(pageContext.pageProps.profile);
const showStashDialog = ref(false);
const showArchived = ref(false);
const sortings = ['used', 'name', 'size', 'created'];
const sorting = ref('size');
async function reloadStashes() {
// profile.value = await get(`/users/${profile.value.id}`);
stashes.value = await get(`/users/${profile.value.id}/stashes`);
}
const sortedStashes = computed(() => stashes.value
.toSorted((stashA, stashB) => {
return stashA.createdAt - stashB.createdAt;
})
.toSorted((stashA, stashB) => {
if (sorting.value === 'used') {
return stashB.lastStashAt - stashA.lastStashAt;
}
if (sorting.value === 'name') {
return stashA.name.localeCompare(stashB.name);
}
if (sorting.value === 'size') {
return (stashB.stashedScenes + stashB.stashedMovies + stashB.stashedActors)
- (stashA.stashedScenes + stashA.stashedMovies + stashA.stashedActors);
}
if (sorting.value === 'created') {
return stashA.createdAt - stashB.createdAt;
}
return 0;
})
.toSorted((stashA, stashB) => {
// always put favorites first
return stashB.isPrimary - stashA.isPrimary;
}));
const activeStashes = computed(() => sortedStashes.value.filter((stash) => !stash.isArchived));
const archivedStashes = computed(() => sortedStashes.value.filter((stash) => stash.isArchived));
function toggleSorting() {
sorting.value = sortings[(sortings.indexOf(sorting.value) + 1) % sortings.length];
}
</script>
<template>
<section class="profile-section">
<div class="section-header">
<div class="section-header noselect">
<button
v-if="profile.id === user?.id"
class="button"
@@ -31,6 +70,38 @@ async function reloadStashes() {
<Icon icon="folder-plus2" />
<span class="button-label">New stash</span>
</button>
<Icon
v-if="sorting === 'used'"
v-tooltip="'By last stash'"
icon="sort-heart"
class="sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'name'"
v-tooltip="'By name'"
icon="sort-alpha-asc"
class="sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'size'"
v-tooltip="'By total stashed'"
icon="sort-amount-desc"
class="sort"
@click="toggleSorting"
/>
<Icon
v-if="sorting === 'created'"
v-tooltip="'By stash age'"
icon="sort-time-asc"
class="sort"
@click="toggleSorting"
/>
</div>
<StashDialog
@@ -41,7 +112,29 @@ async function reloadStashes() {
<ul class="stashes nolist">
<li
v-for="stash in stashes"
v-for="stash in activeStashes"
:key="`stash-${stash.id}`"
>
<StashTile
:stash="stash"
:profile="profile"
@reload="reloadStashes"
/>
</li>
</ul>
<h3
v-if="archivedStashes.length > 0"
class="archived-heading"
@click="showArchived = !showArchived"
><Icon icon="drawer3" />{{ showArchived ? 'Hide' : `Show ${archivedStashes.length}` }} archived {{ archivedStashes.length > 1 ? 'stashes' : 'stash' }}</h3>
<ul
v-if="showArchived"
class="stashes nolist"
>
<li
v-for="stash in archivedStashes"
:key="`stash-${stash.id}`"
>
<StashTile
@@ -59,6 +152,7 @@ async function reloadStashes() {
display: flex;
justify-content: center;
margin-bottom: .5rem;
gap: 1rem;
}
.stashes {
@@ -68,6 +162,30 @@ async function reloadStashes() {
padding: 0 0 1rem 0;
}
.sort {
padding: .5rem 1rem;
fill: var(--glass);
&:hover {
fill: var(--primary);
cursor: pointer;
}
}
.archived-heading {
display: flex;
align-items: center;
font-size: 1rem;
color: var(--glass);
cursor: pointer;
.icon {
fill: var(--glass);
margin-right: .75rem;
transform: translateY(-1px);
}
}
@media(--compact) {
.stashes {
padding: 0 1rem 1rem 1rem;
+47
View File
@@ -91,6 +91,30 @@ async function rename() {
showRenameDialog.value = false;
}
async function archive(isArchived = true) {
if (done.value === false) {
return;
}
done.value = false;
await patch(`/stashes/${props.stash.id}`, { isArchived }, {
...isArchived
? {
undoFeedback: `Stash archived`,
}
: {
successFeedback: `Stash revived`,
},
errorFeedback: `Failed to ${isArchived ? 'archive' : 'revive'} stash`,
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
showRenameDialog.value = false;
}
</script>
<template>
@@ -159,6 +183,28 @@ async function rename() {
/>Rename
</li>
<li
v-if="stash.isArchived"
class="menu-item"
@click="archive(false)"
>
<Icon
icon="drawer-out"
class="noselect"
/>Revive
</li>
<li
v-else
class="menu-item"
@click="archive()"
>
<Icon
icon="drawer-in"
class="noselect"
/>Archive
</li>
<li
v-if="!stash.isPrimary"
class="menu-item remove"
@@ -306,6 +352,7 @@ async function rename() {
display: flex;
margin-right: .75rem;
fill: var(--glass);
transform: translateY(-1px);
}
&.remove {
+1
View File
@@ -206,6 +206,7 @@ module.exports = {
crontab: '*/10 * * * *', // every 10 minutes
},
alerts: {
enabled: true,
crontab: '*/10 * * * *', // every 10 minutes
seenExpiry: 30, // days
finalExpiry: 365, // days
+5 -5
View File
@@ -1,11 +1,11 @@
{
"name": "traxxx-web",
"version": "0.57.11",
"version": "0.59.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"version": "0.57.11",
"version": "0.59.2",
"dependencies": {
"@brillout/json-serializer": "^0.5.25",
"@dicebear/collection": "7.0.5",
@@ -14167,9 +14167,9 @@
}
},
"node_modules/manticoresearch": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/manticoresearch/-/manticoresearch-10.0.0.tgz",
"integrity": "sha512-a6eiAImHjhLLJgDYFRJfw2k4UL+y7ucchCbNN7q3t+6Fo4TvYf+vbS3HOcRv2h5wIFo6yaZ5N09ztKOOGqlhNw==",
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/manticoresearch/-/manticoresearch-10.2.0.tgz",
"integrity": "sha512-dzXZwrSVizGjV4yYjEsuzq4TQqqh9FDaCu173p7wxq2xpHwiSp5FTxiBJcMTUQa1K9Di41RUoDTMWAjUjYYjFA==",
"license": "MIT",
"dependencies": {
"@babel/cli": "^7.0.0",
+1 -1
View File
@@ -92,7 +92,7 @@
"overrides": {
"vite": "$vite"
},
"version": "0.57.11",
"version": "0.59.2",
"imports": {
"#/*": "./*.js"
},
@@ -5,11 +5,13 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
avatars,
} = await fetchActorRevisions(null, {
actorId: actor.id,
isFinalized: true,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -18,6 +20,7 @@ export async function onBeforeRender(pageContext) {
pageProps: {
actor,
revisions,
revisionTotal,
avatars,
},
},
+52 -9
View File
@@ -52,9 +52,12 @@ const fields = computed(() => [
key: 'dateOfBirth',
label: 'date of birth',
type: 'date',
value: actor.value?.dateOfBirth
? format(actor.value.dateOfBirth, 'yyyy-MM-dd')
: null,
value: {
date: actor.value?.dateOfBirth
? format(actor.value.dateOfBirth, 'yyyy-MM-dd')
: null,
precision: actor.value.dateOfBirthPrecision,
},
inline: true,
},
{
@@ -212,9 +215,12 @@ const fields = computed(() => [
key: 'dateOfDeath',
label: 'date of death',
type: 'date',
value: actor.value?.dateOfDeath
? format(actor.value.dateOfDeath, 'yyyy-MM-dd')
: null,
value: {
date: actor.value?.dateOfDeath
? format(actor.value.dateOfDeath, 'yyyy-MM-dd')
: null,
precision: actor.value.dateOfDeathPrecision,
},
},
{
key: 'allowGlobalMatch',
@@ -270,6 +276,14 @@ const keyMap = {
country: 'residenceCountry',
place: 'residencePlace',
},
dateOfBirth: {
date: 'dateOfBirth',
precision: 'dateOfBirthPrecision',
},
dateOfDeath: {
date: 'dateOfDeath',
precision: 'dateOfDeathPrecision',
},
tattoos: {
has: 'hasTattoos',
description: 'tattoos',
@@ -501,6 +515,7 @@ async function submit() {
>{{ item.unit }}
</template>
<!--
<input
v-if="item.type === 'date'"
v-model="edits[item.key]"
@@ -508,6 +523,30 @@ async function submit() {
class="date input"
:disabled="!editing.has(item.key)"
>
-->
<div
v-if="item.type === 'date'"
class="date"
>
<input
v-model="edits[item.key].date"
type="date"
class="date input"
:disabled="!editing.has(item.key)"
>
<select
v-if="item.value.precision"
v-model="edits[item.key].precision"
class="input"
:disabled="!editing.has(item.key)"
>
<option value="day">Day</option>
<option value="month">Month</option>
<option value="year">Year</option>
</select>
</div>
<select
v-if="item.type === 'select'"
@@ -747,7 +786,7 @@ async function submit() {
.row {
display: flex;
align-items: center;
padding: .25rem 1rem;
padding: .75rem 1rem;
margin-bottom: .25rem;
overflow: hidden;
@@ -758,10 +797,14 @@ async function submit() {
width: auto;
}
}
&:not(:last-child) {
border-bottom: solid 1px var(--glass-weak-40);
}
}
.key {
width: 10rem;
width: 9rem;
display: inline-flex;
align-items: center;
text-transform: capitalize;
@@ -906,7 +949,7 @@ async function submit() {
.item-actions {
.icon {
padding: .25rem 1rem;
padding: .25rem 1.5rem .25rem 1rem;
fill: var(--glass);
overflow: hidden;
@@ -10,10 +10,12 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
avatars,
} = await fetchActorRevisions(null, {
isFinalized: false,
limit: 50,
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -21,6 +23,7 @@ export async function onBeforeRender(pageContext) {
title: pageContext.routeParams.section,
pageProps: {
revisions,
revisionTotal,
avatars,
},
},
+3 -1
View File
@@ -1,6 +1,6 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(actors)';
const path = '/admin/:section/:domain(actors)/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -11,6 +11,8 @@ export default (pageContext) => {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
page: matched.params.page || '1',
path,
},
};
}
@@ -10,12 +10,14 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
actors,
tags,
movies,
} = await fetchSceneRevisions(null, {
isFinalized: false,
limit: 50,
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -23,6 +25,7 @@ export async function onBeforeRender(pageContext) {
title: pageContext.routeParams.section,
pageProps: {
revisions,
revisionTotal,
actors,
tags,
movies,
+3 -1
View File
@@ -1,6 +1,6 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(scenes)';
const path = '/admin/:section/:domain(scenes)/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -11,6 +11,8 @@ export default (pageContext) => {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
page: matched.params.page || '1',
path,
},
};
}
+27 -10
View File
@@ -1,17 +1,30 @@
import { getRandomCampaigns } from '#/src/campaigns.js';
import { fetchMovies } from '#/src/movies.js';
import { curateMoviesQuery } from '#/src/web/movies.js';
export async function onBeforeRender(pageContext) {
const movieResults = await fetchMovies(await curateMoviesQuery({
...pageContext.urlQuery,
scope: pageContext.routeParams.scope || 'latest',
}), {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 50,
dedupe: true,
}, pageContext.user, {
restriction: pageContext.geo.restriction,
});
const [
movieResults,
campaigns,
] = await Promise.all([
fetchMovies(await curateMoviesQuery({
...pageContext.urlQuery,
scope: pageContext.routeParams.scope || 'latest',
}), {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 50,
dedupe: true,
}, pageContext.user, {
restriction: pageContext.geo.restriction,
}),
// same banner shapes as the scenes page header and footer
getRandomCampaigns([
{ minRatio: 3 },
{ minRatio: 1.5 },
], { tagFilter: pageContext.tagFilter }),
]);
const [metaCampaign, paginationCampaign] = campaigns;
return {
pageContext: {
@@ -19,6 +32,10 @@ export async function onBeforeRender(pageContext) {
pageProps: {
...movieResults,
},
campaigns: {
meta: metaCampaign,
pagination: paginationCampaign,
},
},
};
}
+3 -1
View File
@@ -21,6 +21,7 @@ export async function onBeforeRender(pageContext) {
restriction: pageContext.geo.restriction,
}),
getRandomCampaigns([
{ minRatio: 3 },
{ minRatio: 0.75, maxRatio: 1.25 },
{ minRatio: 1.5 },
], { tagFilter: pageContext.tagFilter }),
@@ -31,7 +32,7 @@ export async function onBeforeRender(pageContext) {
} = sceneResults;
const campaignIndex = getCampaignIndex(scenes.length);
const [sceneCampaign, paginationCampaign] = campaigns;
const [metaCampaign, sceneCampaign, paginationCampaign] = campaigns;
return {
pageContext: {
@@ -41,6 +42,7 @@ export async function onBeforeRender(pageContext) {
},
campaigns: {
index: campaignIndex,
meta: metaCampaign,
scenes: scenes.length > 5 && sceneCampaign,
pagination: paginationCampaign,
},
+6 -2
View File
@@ -451,7 +451,11 @@ async function submit() {
.row {
display: flex;
align-items: center;
padding: .25rem 1rem;
padding: .75rem 1rem;
&:not(:last-child) {
border-bottom: solid 1px var(--glass-weak-40);
}
.value.disabled {
color: var(--glass);
@@ -512,7 +516,7 @@ async function submit() {
.item-actions {
.icon {
padding: .25rem 1rem;
padding: .25rem 1.5rem .25rem 1rem;
fill: var(--glass);
overflow: hidden;
@@ -10,13 +10,15 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
actors,
tags,
movies,
} = await fetchSceneRevisions(null, {
sceneId: scene.id,
isFinalized: true,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
return {
@@ -25,6 +27,7 @@ export async function onBeforeRender(pageContext) {
pageProps: {
scene,
revisions,
revisionTotal,
actors,
tags,
movies,
+2
View File
@@ -43,6 +43,7 @@ export async function onBeforeRender(pageContext) {
aggActors,
aggTags,
aggChannels,
aggActorCounts,
total: sceneTotal,
} = searchScenes;
@@ -68,6 +69,7 @@ export async function onBeforeRender(pageContext) {
aggActors,
aggTags,
aggChannels,
aggActorCounts,
sceneTotal,
actorTotal,
movieTotal,
+1
View File
@@ -89,6 +89,7 @@ const tagSlugs = {
'free-use',
'latex',
'blindfold',
'body-writing',
],
manual: [
'handjob',
+1 -1
View File
@@ -20,7 +20,7 @@ const domain = pageContext.routeParams.domain;
const user = pageContext.user;
const profile = ref(pageContext.pageProps.profile);
const primaryStash = pageContext.assets.primaryStash;
const primaryStash = pageContext.assets?.primaryStash;
const showFilters = ref(false);
+7 -3
View File
@@ -15,14 +15,16 @@ async function fetchRevisions(pageContext) {
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'scenes') {
return fetchSceneRevisions(null, {
userId: pageContext.user.id,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
}
if (pageContext.routeParams.section === 'revisions' && pageContext.routeParams.domain === 'actors') {
return fetchActorRevisions(null, {
userId: pageContext.user.id,
limit: 100,
limit: Number(pageContext.urlParsed.search.limit) || 100,
page: Number(pageContext.routeParams.page) || 1,
}, pageContext.user);
}
@@ -31,7 +33,7 @@ async function fetchRevisions(pageContext) {
export async function onBeforeRender(pageContext) {
const [profile, alerts, userRevisions, keys] = await Promise.all([
fetchUser(pageContext.routeParams.username, {}, pageContext.user),
fetchUser(pageContext.routeParams.username, { throwError: false }, pageContext.user),
pageContext.routeParams.section === 'alerts' && pageContext.routeParams.username === pageContext.user?.username
? fetchAlerts(pageContext.user)
: [],
@@ -47,6 +49,7 @@ export async function onBeforeRender(pageContext) {
const {
revisions,
total: revisionTotal,
actors,
tags,
movies,
@@ -63,6 +66,7 @@ export async function onBeforeRender(pageContext) {
stashes,
alerts,
revisions,
revisionTotal,
keys,
actors,
tags,
+3 -1
View File
@@ -1,7 +1,7 @@
import { match } from 'path-to-regexp';
import { redirect } from 'vike/abort';
const path = '/user/:username/:section?/:domain?';
const path = '/user/:username/:section?/:domain?/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
@@ -18,6 +18,8 @@ export default (pageContext) => {
username: matched.params.username,
section: matched.params.section || '',
domain: matched.params.domain || '',
page: matched.params.page || '1',
path,
},
};
}
+1 -1
View File
@@ -67,7 +67,7 @@ async function onRenderHtml(pageContext) {
<meta name="theme-color" content="#f65596">
<meta property="og:title" content="traxxx" />
<meta property="og:image" content="https://traxxx.me/img/og_logo.png" />
<meta property="og:description" content="${pageContext.description || 'Never miss new adult videos with traxxx'}" />
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,interactive-widget=resizes-content" />
+92 -23
View File
@@ -24,7 +24,7 @@ import { curateMedia } from './media.js';
import redis from './redis.js';
import { curateRevision } from './revisions.js';
import { curateStash } from './stashes.js';
import { syncActors, syncScenes, syncStashes } from './sync.js';
import { syncActors, syncManticoreScenes, syncScenes, syncStashes } from './sync.js';
const logger = initLogger();
const mj = new MerkleJson();
@@ -32,7 +32,9 @@ const mj = new MerkleJson();
const keyMap = {
avatar: 'avatar_media_id',
dateOfBirth: 'date_of_birth',
dateOfBirthPrecision: 'date_of_birth_precision',
dateOfDeath: 'date_of_death',
dateOfDeathPrecision: 'date_of_death_precision',
originCountry: 'birth_country_alpha2',
originState: 'birth_state',
originCity: 'birth_city',
@@ -62,6 +64,24 @@ const keyMap = {
const socialsOrder = ['onlyfans', 'fansly', 'twitter', 'instagram', 'loyalfans', 'manyvids', 'pornhub', 'linktree', null];
// with month (but not day) precision on either side, the age is still certain unless both dates fall in the same month,
// since only then could the unknown day(s) put the birthday on either side of the reference date
function isAgeApproximate(baseDate, basePrecision, referenceDate, referencePrecision = 'day') {
if (!baseDate || !referenceDate) {
return false;
}
if (basePrecision === 'year' || referencePrecision === 'year') {
return true;
}
if (basePrecision === 'day' && referencePrecision === 'day') {
return false;
}
return baseDate.getMonth() === referenceDate.getMonth();
}
export function curateActor(actor, context = {}) {
if (!actor) {
return null;
@@ -97,14 +117,20 @@ export function curateActor(actor, context = {}) {
ageFromBirth: actor.date_of_birth && actor.date_of_birth.getFullYear() > 1
? differenceInYears(Date.now(), actor.date_of_birth)
: null,
ageFromBirthIsApproximate: actor.date_of_birth_precision !== 'day'
&& isAgeApproximate(actor.date_of_birth, actor.date_of_birth_precision, new Date()),
ageAtDeath: actor.date_of_birth && actor.date_of_death && actor.date_of_birth.getFullYear() > 1
? differenceInYears(actor.date_of_death, actor.date_of_birth)
: null,
ageAtDeathIsApproximate: (actor.date_of_birth_precision !== 'day' || actor.date_of_death_precision !== 'day')
&& isAgeApproximate(actor.date_of_birth, actor.date_of_birth_precision, actor.date_of_death, actor.date_of_death_precision),
ageThen: context.sceneDate && actor.date_of_birth && actor.date_of_birth.getFullYear() > 1
? differenceInYears(context.sceneDate, actor.date_of_birth)
: null,
dateOfBirth: actor.date_of_birth,
dateOfBirthPrecision: actor.date_of_birth_precision,
dateOfDeath: actor.date_of_death,
dateOfDeathPrecision: actor.date_of_death_precision,
bust: actor.bust,
cup: actor.cup,
waist: actor.waist,
@@ -209,15 +235,17 @@ export function sortActorsByGender(actors, context = {}) {
return actors;
}
const alphaActors = actors.sort((actorA, actorB) => actorA.name.localeCompare(actorB.name, 'en'));
const genderActors = ['transsexual', 'female', undefined, null, 'male'].flatMap((gender) => alphaActors.filter((actor) => actor.gender === gender));
const alphaActors = actors.toSorted((actorA, actorB) => actorA.name?.localeCompare(actorB.name, 'en'));
const titleSlug = slugify(context.title);
const titleActors = titleSlug
? genderActors.sort((actorA, actorB) => {
const actorASlug = actorA.slug.split('-')[0];
const actorBSlug = actorB.slug.split('-')[0];
? alphaActors.sort((actorA, actorB) => {
const actorASlug = actorA.slug?.split('-')[0];
const actorBSlug = actorB.slug?.split('-')[0];
if (!actorASlug || !actorBSlug) {
return 0;
}
if (titleSlug.includes(actorASlug) && !titleSlug.includes(actorBSlug)) {
return -1;
@@ -231,7 +259,10 @@ export function sortActorsByGender(actors, context = {}) {
})
: alphaActors;
return titleActors;
const genderActors = ['transsexual', 'female', undefined, null, 'male'].flatMap((gender) => titleActors.filter((actor) => actor.gender === gender));
const identifiedActors = genderActors.toSorted((actorA, actorB) => !!actorA.isUnknown - !!actorB.isUnknown);
return identifiedActors;
}
export async function fetchActorsById(actorIds, options = {}, reqUser) {
@@ -439,22 +470,21 @@ async function queryManticoreSql(filters, options, _reqUser) {
builder.select('if(date_of_birth, floor((now() - date_of_birth) / 31556952), 0) as age');
}
// range filters
['age', 'height'].forEach((attribute) => {
if (filters[attribute]) {
builder
.where(attribute, '>=', filters[attribute][0])
.where(attribute, '<=', filters[attribute][1]);
// range filters, either end may be open, weight is a reserved keyword in manticore
Object.entries({ age: 'age', height: 'height', weight: 'mass' }).forEach(([attribute, column]) => {
if (typeof filters[attribute]?.min === 'number') {
builder.where(column, '>=', filters[attribute].min);
}
if (typeof filters[attribute]?.max === 'number') {
builder.where(column, '<=', filters[attribute].max);
if (typeof filters[attribute].min !== 'number') {
builder.where(column, '>', 0); // unknown values are stored as 0, an open lower bound should not match them
}
}
});
if (filters.weight) {
// weight is a reserved keyword in manticore
builder
.where('mass', '>=', filters.weight[0])
.where('mass', '<=', filters.weight[1]);
}
if (filters.dateOfBirth && filters.dobType === 'dateOfBirth') {
builder.where('date_of_birth', Math.floor(filters.dateOfBirth.getTime() / 1000));
}
@@ -471,7 +501,8 @@ async function queryManticoreSql(filters, options, _reqUser) {
}
if (filters.cup) {
builder.select(`regex(actors.cup, '^[${filters.cup[0]}-${filters.cup[1]}]') as cup_in_range`);
// cup range is validated to single letters by the query parser
builder.select(`regex(actors.cup, '^[${filters.cup.min || 'A'}-${filters.cup.max || 'Z'}]') as cup_in_range`);
builder.where('cup_in_range', 1);
}
@@ -1059,6 +1090,7 @@ export async function fetchActorRevisions(revisionId, filters = {}, reqUser) {
'actors_revisions.*',
'users.username as username',
'reviewers.username as reviewer_username',
knex.raw('count(*) over() as total'),
)
.leftJoin('users', 'users.id', 'actors_revisions.user_id')
.leftJoin('users as reviewers', 'reviewers.id', 'actors_revisions.reviewed_by')
@@ -1105,6 +1137,7 @@ export async function fetchActorRevisions(revisionId, filters = {}, reqUser) {
return {
revisions: curatedRevisions,
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
total: Number(revisions[0]?.total) || 0,
avatars,
};
}
@@ -1167,6 +1200,36 @@ async function fetchMainProfile(actorId, wasCreated = false) {
return fetchMainProfile(actorId, true);
}
async function fetchActorGenders(actorIds) {
const actors = await knex('actors')
.select('id', 'gender')
.whereIn('id', actorIds);
return Object.fromEntries(actors.map((actor) => [actor.id, actor.gender]));
}
// scene search documents count actors per gender, so scenes need a resync when an actor's gender changes
// syncs the search documents directly, the materialized views don't depend on actor genders
async function syncGenderChangedScenes(actorIds, gendersBefore) {
const gendersAfter = await fetchActorGenders(actorIds);
const changedActorIds = actorIds.filter((actorId) => gendersAfter[actorId] !== gendersBefore[actorId]);
if (changedActorIds.length === 0) {
return;
}
const sceneIds = await knex('releases_actors')
.distinct('release_id')
.whereIn('actor_id', changedActorIds)
.pluck('release_id');
logger.info(`Gender changed for ${changedActorIds.length} actors, resyncing ${sceneIds.length} scenes`);
if (sceneIds.length > 0) { // without IDs, all scenes are synced
await syncManticoreScenes(sceneIds);
}
}
async function applyActorRevision(revisionIds, reqUser) {
const revisions = await knex('actors_revisions')
.whereIn('id', revisionIds)
@@ -1183,7 +1246,9 @@ async function applyActorRevision(revisionIds, reqUser) {
'gender',
'avatar',
'dateOfBirth',
'dateOfBirthPrecision',
'dateOfDeath',
'dateOfDeathPrecision',
'originCountry',
'originState',
'originCity',
@@ -1246,6 +1311,7 @@ async function applyActorRevision(revisionIds, reqUser) {
}, Promise.resolve());
const actorIds = Array.from(new Set(revisions.map((revision) => revision.actor_id)));
const gendersBefore = await fetchActorGenders(actorIds);
await interpolateProfiles(actorIds, {
knex,
@@ -1255,7 +1321,10 @@ async function applyActorRevision(revisionIds, reqUser) {
omit,
}, { refreshView: false });
await syncActors(actorIds);
await Promise.all([
syncActors(actorIds),
syncGenderChangedScenes(actorIds, gendersBefore),
]);
}
export async function reviewActorRevision(revisionId, isApproved, { feedback }, reqUser) {
+2 -1
View File
@@ -738,6 +738,7 @@ export async function notify(sceneIds, options = {}) {
.insert(stashEntries)
.onConflict(['stash_id', 'scene_id'])
.ignore()
.returning('id')
: [],
notifications.length > 0
? knex('notifications')
@@ -754,7 +755,7 @@ export async function notify(sceneIds, options = {}) {
const docs = stashedEntries.map((stash) => ({
replace: {
index: 'scenes_stashed',
table: 'scenes_stashed',
id: stash.id,
doc: {
scene_id: stash.scene_id,
+8
View File
@@ -628,6 +628,14 @@ export async function verifyKey(userId, key, req) {
throw new HttpError('The API credentials are not provided.', 401);
}
if (typeof userId !== 'number') {
throw new HttpError('User ID is not a number', 400);
}
if (typeof key !== 'string') {
throw new HttpError('Key is not a string', 400);
}
const hashedKey = (await scrypt(key, '', 64)).toString('hex'); // salt redundant for randomly generated key
const storedKey = await knex('users_keys')
+25 -2
View File
@@ -289,6 +289,14 @@ async function queryManticoreSql(filters, options) {
builder.whereIn('effective_year', filters.years);
}
if (typeof filters.yearRange?.min === 'number') {
builder.where('effective_year', '>=', filters.yearRange.min);
}
if (typeof filters.yearRange?.max === 'number') {
builder.where('effective_year', '<=', filters.yearRange.max);
}
filters.tagIds?.forEach((tagId) => {
builder.where('any(tag_ids)', tagId);
});
@@ -428,9 +436,24 @@ export async function fetchMovies(filters, rawOptions, reqUser, context) {
console.log(options);
console.log(filters);
const result = await queryManticoreSql(filters, options);
// an active year filter would narrow the year range to the filtered years, get the full range from a lightweight parallel query
const hasYearFilter = options.aggregateYears && (filters.years?.length > 0 || !!filters.yearRange);
const aggYears = options.aggregateYears && result.aggregations.years.map((bucket) => ({ year: bucket.key, count: bucket.doc_count }));
const yearsOptions = {
...options,
limit: 1,
page: 1,
aggregateActors: false,
aggregateTags: false,
aggregateChannels: false,
};
const [result, yearsResult] = await Promise.all([
queryManticoreSql(filters, options),
hasYearFilter ? queryManticoreSql({ ...filters, years: [], yearRange: null }, yearsOptions) : null,
]);
const aggYears = options.aggregateYears && (yearsResult || result).aggregations.years.map((bucket) => ({ year: bucket.key, count: bucket.doc_count }));
const actorCounts = options.aggregateActors && countAggregations(result.aggregations?.actorIds);
const tagCounts = options.aggregateTags && countAggregations(result.aggregations?.tagIds);
+130 -16
View File
@@ -79,9 +79,12 @@ function curateScene(rawScene, assets, reqUser, context) {
entityId: assets.channel.affiliate.entity_id,
}
: null,
actors: sortActorsByGender(assets.actors.map((actor) => curateActor(actor, {
sceneDate: rawScene.effective_date,
stashes: assets.actorStashes.filter((actorStash) => actorStash.actor_id === actor.id),
actors: sortActorsByGender(assets.actors.map((actor) => ({
...curateActor(actor, {
sceneDate: rawScene.effective_date,
stashes: assets.actorStashes.filter((actorStash) => actorStash.actor_id === actor.id),
}),
isUnknown: !!actor.isUnknown,
})), { title: rawScene.title }),
directors: assets.directors.map((director) => ({
id: director.id,
@@ -127,7 +130,7 @@ function curateScene(rawScene, assets, reqUser, context) {
title: serie.title,
poster: context.restriction
? null
: (serie.serie_poster, { type: 'poster' }),
: curateMedia(serie.serie_poster, { type: 'poster' }),
})),
poster: curateMedia(assets.poster, { type: 'poster' }),
photos: assets.photos?.map((photo) => curateMedia(photo, { type: 'photo' })) || [],
@@ -228,6 +231,8 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
'countries.name as birth_country_name',
'countries.alias as birth_country_alias',
'releases_actors.release_id',
'releases_actors.id as release_actor_id',
'releases_actors.gender as release_actor_gender',
)
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
.leftJoin('actors as aliases', 'aliases.id', 'releases_actors.alias_id')
@@ -236,7 +241,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
.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', 'aliases.id', 'releases_actors.release_id', 'avatars.id', 'media_biometrics.id', 'countries.name', 'countries.alias', 'sfw_media.id'),
.groupBy('releases_actors.id', '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'),
@@ -385,7 +390,15 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
const sceneChannel = channels.find((entity) => entity.id === scene.entity_id);
const sceneStudio = studios.find((entity) => entity.id === scene.studio_id);
const sceneActors = actors.filter((actor) => actor.release_id === sceneId);
const sceneActors = actors.filter((actor) => actor.release_id === sceneId).map((actor) => (actor.id
? actor
: {
...actor,
// unidentified actor, needs a unique ID for editing, encodes gender for storage
id: `${actor.release_actor_gender || 'other'}_${actor.release_actor_id}`,
gender: actor.release_actor_gender,
isUnknown: true,
}));
const sceneDirectors = directors.filter((director) => director.release_id === sceneId);
const sceneTags = tags.filter((tag) => tag.release_id === sceneId);
const sceneChapters = chapters.filter((chapter) => chapter.release_id === sceneId);
@@ -439,6 +452,7 @@ function curateOptions(options) {
aggregateActors: (options?.aggregate ?? true) && (options?.aggregateActors ?? true),
aggregateTags: (options?.aggregate ?? true) && (options?.aggregateTags ?? true),
aggregateChannels: (options?.aggregate ?? true) && (options?.aggregateChannels ?? true),
aggregateActorCounts: (options?.aggregate ?? true) && (options?.aggregateActorCounts ?? true),
dedupe: !!options?.dedupe,
index: options?.index || 'scenes',
useSql: options?.useSql || (typeof options?.useSql === 'undefined' && sqlImplied.includes(options?.index)) || false,
@@ -446,12 +460,12 @@ function curateOptions(options) {
}
// function curateFacet(results, field, count = 'count(distinct id)') {
function curateFacet(results, field) {
function curateFacet(results, field, { includeZero = false } = {}) {
return results
.find((result) => result.columns[0][field] && (result.columns[1]['count(distinct id)'] || result.columns[1]['count(*)']))
?.data
.map((row) => ({ key: row[field], doc_count: row['count(distinct id)'] || row['count(*)'] }))
.filter((row) => !!row.key)
.filter((row) => !!row.key || (includeZero && row.key === 0)) // zero is a meaningful actor count, e.g. no men
|| [];
}
@@ -492,7 +506,11 @@ async function queryManticoreSql(filters, options, _reqUser) {
:actorsFacet:
:tagsFacet:
:channelsFacet:
:studiosFacet:;
:studiosFacet:
:groupFacet:
:femalesFacet:
:malesFacet:
:transFacet:;
show meta;
`, {
query: knexManticore(filters.stashId ? 'scenes_stashed' : 'scenes')
@@ -502,6 +520,11 @@ async function queryManticoreSql(filters, options, _reqUser) {
scenes.id as id,
scenes.title as title,
scenes.actor_ids as actor_ids,
scenes.actor_count as actor_count,
scenes.female_count as female_count,
scenes.male_count as male_count,
scenes.trans_count as trans_count,
scenes.unidentified_count as unidentified_count,
scenes.entity_ids as entity_ids,
scenes.tag_ids as tag_ids,
scenes.channel_id as channel_id,
@@ -535,6 +558,14 @@ async function queryManticoreSql(filters, options, _reqUser) {
builder.whereIn('effective_year', filters.years);
}
if (typeof filters.yearRange?.min === 'number') {
builder.where('effective_year', '>=', filters.yearRange.min);
}
if (typeof filters.yearRange?.max === 'number') {
builder.where('effective_year', '<=', filters.yearRange.max);
}
filters.tagIds?.forEach((tagId) => {
if (filters.onlyActorTags) {
builder.where((whereBuilder) => {
@@ -562,6 +593,23 @@ async function queryManticoreSql(filters, options, _reqUser) {
builder.whereNotIn('actor_ids', filters.notActorIds);
}
// actor counts include unidentified actors, gender counts only actors with a known gender
Object.entries({
actor_count: filters.actorCount,
female_count: filters.femaleCount,
male_count: filters.maleCount,
trans_count: filters.transCount,
unidentified_count: filters.unidentifiedCount,
}).forEach(([field, range]) => {
if (typeof range?.min === 'number') {
builder.where(`scenes.${field}`, '>=', range.min);
}
if (typeof range?.max === 'number') {
builder.where(`scenes.${field}`, '<=', range.max);
}
});
if (filters.entityId) {
builder.whereRaw('any(entity_ids) = ?', filters.entityId);
@@ -644,6 +692,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
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,
groupFacet: options.aggregateActorCounts ? knex.raw('facet scenes.actor_count as group_facet order by actor_count asc limit ?', [aggSize]) : null,
femalesFacet: options.aggregateActorCounts ? knex.raw('facet scenes.female_count as females_facet order by female_count asc limit ?', [aggSize]) : null,
malesFacet: options.aggregateActorCounts ? knex.raw('facet scenes.male_count as males_facet order by male_count asc limit ?', [aggSize]) : null,
transFacet: options.aggregateActorCounts ? knex.raw('facet scenes.trans_count as trans_facet order by trans_count asc limit ?', [aggSize]) : null,
maxMatches: config.database.manticore.maxMatches,
maxQueryTime: config.database.manticore.maxQueryTime,
}).toString();
@@ -667,6 +719,13 @@ async function queryManticoreSql(filters, options, _reqUser) {
const channelIds = curateFacet(results, 'channels_facet');
const studioIds = curateFacet(results, 'studios_facet');
const actorCounts = {
group: curateFacet(results, 'group_facet', { includeZero: true }),
females: curateFacet(results, 'females_facet', { includeZero: true }),
males: curateFacet(results, 'males_facet', { includeZero: true }),
trans: curateFacet(results, 'trans_facet', { includeZero: true }),
};
const allTagIds = mergePackedTags(tagIds);
const actorTagIds = mergePackedTags(tagIds.filter((tag) => {
@@ -696,6 +755,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
actorTagIds,
channelIds,
studioIds,
actorCounts,
},
};
}
@@ -708,6 +768,14 @@ function countAggregations(buckets) {
return Object.fromEntries(buckets.map((bucket) => [bucket.key, { count: bucket.doc_count }]));
}
// URL parameter and aggregation key to filter key
const actorCountFilters = {
group: 'actorCount',
females: 'femaleCount',
males: 'maleCount',
trans: 'transCount',
};
export async function fetchScenes(filters, rawOptions, reqUser, context) {
const options = curateOptions(rawOptions);
@@ -716,15 +784,46 @@ export async function fetchScenes(filters, rawOptions, reqUser, context) {
console.log('options', options);
}
// an active count or year filter would narrow its own aggregation to the filtered values, get the unfiltered ranges from a lightweight parallel query (~10ms vs 40-500ms for the main query with its actor and tag facets)
// the range filters are stripped together, so with several active, each of their aggregations ignores the others
const activeCountKeys = options.aggregateActorCounts
? Object.keys(actorCountFilters).filter((key) => filters[actorCountFilters[key]])
: [];
const hasYearFilter = options.aggregateYears && (filters.years?.length > 0 || !!filters.yearRange);
const rangeFilterKeys = [...Object.values(actorCountFilters), 'years', 'yearRange'];
const countsFilters = Object.fromEntries(Object.entries(filters).filter(([key]) => !rangeFilterKeys.includes(key)));
const countsOptions = {
...options,
limit: 1,
page: 1,
aggregateYears: hasYearFilter,
aggregateActors: false,
aggregateTags: false,
aggregateChannels: false,
};
console.time('manticore sql');
const result = await queryManticoreSql(filters, options, reqUser);
const [result, countsResult] = await Promise.all([
queryManticoreSql(filters, options, reqUser),
activeCountKeys.length > 0 || hasYearFilter ? queryManticoreSql(countsFilters, countsOptions, reqUser) : null,
]);
console.timeEnd('manticore sql');
const aggYears = options.aggregateYears && result.aggregations.years.map((bucket) => ({ year: bucket.key, count: bucket.doc_count }));
const aggYears = options.aggregateYears && (hasYearFilter ? countsResult : result).aggregations.years.map((bucket) => ({ year: bucket.key, count: bucket.doc_count }));
const entityIds = options.aggregateChannels && [...(result.aggregations.channelIds || []), ...(result.aggregations.studioIds || [])];
// keyed by URL parameter, e.g. { group: [{ value: 2, count: 1234 }, ...], females: [...] }, sorted by value so the first and last bucket give the range
// filtered counts take their range from the query without count filters, so with several count filters, each of their ranges ignores the others
const aggActorCounts = options.aggregateActorCounts && Object.fromEntries(Object.keys(actorCountFilters).map((key) => [
key,
(activeCountKeys.includes(key) ? countsResult : result).aggregations.actorCounts[key].map((bucket) => ({ value: bucket.key, count: bucket.doc_count })),
]));
const actorCounts = options.aggregateActors && countAggregations(result.aggregations?.actorIds);
const tagCounts = options.aggregateTags && countAggregations(result.aggregations?.tagIds);
const channelCounts = options.aggregateChannels && countAggregations(entityIds);
@@ -752,6 +851,7 @@ export async function fetchScenes(filters, rawOptions, reqUser, context) {
aggTags,
aggActorTags,
aggChannels,
aggActorCounts,
total: result.total,
limit: options.limit,
};
@@ -766,6 +866,7 @@ export async function fetchSceneRevisions(revisionId, filters = {}, reqUser) {
'scenes_revisions.*',
'users.username as username',
'reviewers.username as reviewer_username',
knexOwner.raw('count(*) over() as total'),
)
.leftJoin('users', 'users.id', 'scenes_revisions.user_id')
.leftJoin('users as reviewers', 'reviewers.id', 'scenes_revisions.reviewed_by')
@@ -808,7 +909,7 @@ export async function fetchSceneRevisions(revisionId, filters = {}, reqUser) {
...(revision.deltas.find((delta) => delta.key === 'actors')?.value || []),
...revision.base.tags.map((tag) => tag.actorId),
...revision.deltas.find((delta) => delta.key === 'tags')?.value.map((tag) => tag.actorId) || [],
].filter(Boolean))));
].filter((actorId) => typeof actorId === 'number')))); // unidentified actors have string IDs
const tagIds = Array.from(new Set(revisions.flatMap((revision) => [...revision.base.tags, ...(revision.deltas.find((delta) => delta.key === 'tags')?.value || [])].map((tag) => tag.id))));
const movieIds = Array.from(new Set(revisions.flatMap((revision) => [...revision.base.movies, ...(revision.deltas.find((delta) => delta.key === 'movies')?.value || [])])));
@@ -824,6 +925,7 @@ export async function fetchSceneRevisions(revisionId, filters = {}, reqUser) {
return {
revisions: curatedRevisions,
revision: revisionId && curatedRevisions.find((revision) => revision.id === revisionId),
total: Number(revisions[0]?.total) || 0,
actors,
tags,
movies,
@@ -853,10 +955,22 @@ async function applySceneActorsDelta(sceneId, delta, trx) {
if (delta.value.length > 0) {
await knexOwner('releases_actors')
.insert(delta.value.map((actorId) => ({
release_id: sceneId,
actor_id: actorId,
})))
.insert(delta.value.map((actorId) => {
if (typeof actorId === 'number') {
return {
release_id: sceneId,
actor_id: actorId,
};
}
const gender = actorId.match(/^([a-z]+)_/)?.[1];
return {
release_id: sceneId,
actor_id: null,
gender: ['male', 'female', 'transsexual'].includes(gender) ? gender : null,
};
}))
.transacting(trx);
}
}
+3 -1
View File
@@ -25,6 +25,7 @@ export function curateStash(stash, assets = {}) {
slug: stash.slug,
isPrimary: stash.primary,
isPublic: stash.public,
isArchived: stash.archived,
createdAt: stash.created_at,
stashedScenes: stash.stashed_scenes ?? null,
stashedMovies: stash.stashed_movies ?? null,
@@ -65,7 +66,8 @@ function curateStashEntry(stash, user) {
user_id: user?.id || undefined,
name: stash.name || undefined,
slug: slugify(stash.name) || undefined,
public: stash.isPublic ?? false,
public: stash.isPublic ?? undefined,
archived: stash.isArchived ?? undefined,
comment: stash.comment,
meta: stash.meta,
};
+11
View File
@@ -117,6 +117,12 @@ export async function syncManticoreScenes(sceneIds) {
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 (actors_aliases.id, actors_aliases.name)) FILTER (WHERE actors_aliases.id IS NOT NULL), '[]') as actors_aliases,
-- count release actor rows rather than actors to include unidentified actors, distinct because the other joins multiply rows
COUNT(DISTINCT local_actors.id) as actor_count,
COUNT(DISTINCT local_actors.id) FILTER (WHERE COALESCE(actors.gender, local_actors.gender) = 'female') as female_count,
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 (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,
@@ -240,6 +246,11 @@ export async function syncManticoreScenes(sceneIds) {
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), // 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(),
actor_count: Number(scene.actor_count), // postgres returns counts as bigint strings
female_count: Number(scene.female_count),
male_count: Number(scene.male_count),
trans_count: Number(scene.trans_count),
unidentified_count: Number(scene.unidentified_count),
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
+6 -5
View File
@@ -1,6 +1,8 @@
import { Router } from 'express';
import omit from 'object.omit';
import { parseLetterRange, parseRange } from '../../utils/parse-range.js';
import {
createActor,
createActorRevision,
@@ -10,21 +12,20 @@ import {
mergeActors,
reviewActorRevision,
} from '../actors.js';
import { fetchStashByUsernameAndSlug } from '../stashes.js';
export function curateActorsQuery(query) {
return {
query: query.q,
gender: query.gender,
age: query.age?.split(',').map((age) => Number(age)),
age: parseRange(query.age),
dateOfBirth: query.dob && new Date(query.dob),
dobType: ({ dob: 'dateOfBirth', bd: 'birthday' })[query.dobt] || 'birthday',
cup: query.cup?.split(','),
cup: parseLetterRange(query.cup),
country: query.c,
naturalBoobs: query.nb,
height: query.height?.split(',').map((height) => Number(height)),
weight: query.weight?.split(',').map((weight) => Number(weight)),
height: parseRange(query.height),
weight: parseRange(query.weight),
requireAvatar: query.avatar,
stashId: Number(query.stashId) || null,
isGlobal: Object.hasOwn(query, 'global'),
+1 -1
View File
@@ -112,7 +112,7 @@ export async function graphqlApi(req, res) {
return;
}
await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
await verifyKey(Number(req.headers['api-user']), req.headers['api-key'], req);
req.user = {
id: Number(req.headers['api-user']),
+2 -1
View File
@@ -1,3 +1,4 @@
import { parseYears } from '../../utils/parse-range.js';
import promiseProps from '../../utils/promise-props.js';
import slugify from '../../utils/slugify.js';
import { getIdsBySlug } from '../cache.js';
@@ -10,7 +11,7 @@ export async function curateMoviesQuery(query) {
return {
scope: query.scope || 'latest',
query: query.q,
years: query.years?.split(',')?.map((year) => Number(year)).filter(Boolean) || [],
...parseYears(query.years),
actorIds: [query.actorId, ...(query.actors?.split(',') || []).map((identifier) => parseActorIdentifier(identifier)?.id)].filter(Boolean),
tagIds: await getIdsBySlug([query.tagSlug, ...(query.tags?.split(',') || [])], 'tags'),
entityId: query.e ? await getIdsBySlug([query.e], 'entities').then(([id]) => id) : query.entityId,
+24 -3
View File
@@ -1,7 +1,8 @@
import { Router } from 'express';
import promiseProps from '../../utils/promise-props.js';
import { parseRange, parseYears } from '../../utils/parse-range.js';
import promiseProps from '../../utils/promise-props.js';
import slugify from '../../utils/slugify.js';
import { getIdsBySlug } from '../cache.js';
@@ -17,7 +18,7 @@ import {
import { fetchStashByUsernameAndSlug } from '../stashes.js';
export async function curateScenesQuery(query) {
const splitYears = query.years?.split(',') || [];
const { years, yearRange } = parseYears(query.years);
const splitTags = query.tags?.split(',') || [];
const splitActors = query.actors?.split(',') || [];
const splitEntities = query.e?.split(',') || [];
@@ -38,9 +39,15 @@ export async function curateScenesQuery(query) {
return {
scope: query.scope || 'latest',
query: query.q,
years: splitYears.map((year) => Number(year)).filter(Boolean) || [],
years,
yearRange,
actorIds: [query.actorId, ...splitActors.filter((actor) => actor.charAt(0) !== '!').map((identifier) => parseActorIdentifier(identifier)?.id)].filter(Boolean),
notActorIds: splitActors.filter((actor) => actor.charAt(0) === '!').map((identifier) => parseActorIdentifier(identifier.slice(1))?.id).filter(Boolean),
actorCount: parseRange(query.group),
femaleCount: parseRange(query.females),
maleCount: parseRange(query.males),
transCount: parseRange(query.trans),
unidentifiedCount: parseRange(query.unidentified), // for curators, e.g. unidentified=1- finds scenes with unidentified actors
tagIds,
notTagIds: notTagIds.filter((tagId) => !tagIds.includes(tagId)), // included tags get priority over excluded tags
onlyActorTags: !!query.at,
@@ -61,6 +68,7 @@ async function fetchScenesApi(req, res) {
aggTags,
aggActorTags,
aggChannels,
aggActorCounts,
limit,
total,
} = await fetchScenes(await curateScenesQuery({
@@ -80,6 +88,7 @@ async function fetchScenesApi(req, res) {
aggTags,
aggActorTags,
aggChannels,
aggActorCounts,
limit,
total,
});
@@ -131,6 +140,7 @@ export const scenesSchema = `
network: Entity
actors: [Actor!]!
tags: [Tag!]!
chapters: [Chapter!]!
poster: Media
trailer: Media
photos: [Media!]!
@@ -160,6 +170,17 @@ export const scenesSchema = `
size: Int
createdAt: Int
}
type Chapter {
id: Int!
time: Int
tags: [Tag!]!
date: Date
duration: Int
description: String
title: String
poster: Media
}
`;
function getScope(query) {
+1 -1
View File
@@ -119,7 +119,7 @@ export default async function initServer() {
router.use('/api/{*splat}', async (req, _res, next) => {
if (req.headers['api-user']) {
req.user = await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
req.user = await verifyKey(Number(req.headers['api-user']), req.headers['api-key'], req);
}
next();
+33 -36
View File
@@ -1,45 +1,42 @@
import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js';
import { syncManticoreActors } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() {
if (argv.update) {
await utilsApi.sql('drop table if exists actors');
await utilsApi.sql(`create table actors(
id int,
name text,
aliases text,
slug string,
entity_id int,
alias_for int,
gender string,
date_of_birth timestamp,
country string,
has_avatar bool,
mass int,
height int,
cup string,
natural_boobs int,
penis_length int,
penis_girth int,
stashed int,
scenes int
) min_prefix_len = '3'`);
export async function rebuildActors() {
await utilsApi.sql('drop table if exists actors');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table actors(
id int,
name text,
aliases text,
slug string,
entity_id int,
alias_for int,
gender string,
date_of_birth bigint,
country string,
has_avatar bool,
mass int,
height int,
cup string,
natural_boobs int,
penis_length int,
penis_girth int,
stashed int,
scenes int
) min_prefix_len = '3'`);
console.log('Recreated actors table, syncing actors...');
console.log('Recreated actors table, syncing actors...');
const data = await syncManticoreActors();
console.log('data', data);
knex.destroy();
return;
}
knex.destroy();
await syncManticoreActors();
}
init();
if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildActors();
}
});
}
+38 -37
View File
@@ -1,45 +1,46 @@
import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js';
import { syncManticoreMovies } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() {
if (argv.update) {
await utilsApi.sql('drop table if exists movies');
await utilsApi.sql(`create table movies (
id int,
title text,
title_filtered text,
channel_id int,
channel_name text,
channel_slug text,
network_id int,
network_name text,
network_slug text,
entity_ids multi,
actor_ids multi,
actors text,
tag_ids multi,
tags text,
meta text,
date timestamp,
has_cover bool,
created_at timestamp,
effective_date timestamp,
stashed int,
stashed_scenes int,
stashed_total int,
dupe_index int
)`);
export async function rebuildMovies() {
await utilsApi.sql('drop table if exists movies');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table movies (
id int,
title text,
title_filtered text,
channel_id int,
channel_name text,
channel_slug text,
network_id int,
network_name text,
network_slug text,
entity_ids multi,
actor_ids multi,
actors text,
tag_ids multi,
tags text,
meta text,
date bigint,
has_cover bool,
created_at bigint,
effective_date bigint,
stashed int,
stashed_scenes int,
stashed_total int,
dupe_index int
)`);
console.log('Recreated movies tables, syncing movies...');
console.log('Recreated movies tables, syncing movies...');
const data = await syncManticoreMovies();
console.log('data', data);
}
knex.destroy();
await syncManticoreMovies();
}
init();
if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildMovies();
}
});
}
+61 -53
View File
@@ -1,63 +1,71 @@
import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js';
import { syncManticoreScenes } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() {
if (argv.update) {
await utilsApi.sql('drop table if exists scenes');
await utilsApi.sql(`create table scenes (
id int,
title text,
title_filtered text,
entry_id text,
shoot_id text,
channel_id int,
channel_name text,
channel_slug text,
network_id int,
network_name text,
network_slug text,
studio_id int,
studio_name text,
studio_slug text,
entity_ids multi,
actor_ids multi,
actors text,
tag_ids multi,
assigned_tag_ids multi64,
tags text,
movie_ids multi,
movies text,
serie_ids multi,
series text,
meta text,
date timestamp,
fingerprints text,
is_showcased bool,
created_at timestamp,
effective_date timestamp,
stashed int,
dupe_index int
)`);
export async function rebuildScenes() {
await utilsApi.sql('drop table if exists scenes');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table scenes (
id int,
title text,
title_filtered text,
entry_id text,
shoot_id text,
channel_id int,
channel_name text,
channel_slug text,
network_id int,
network_name text,
network_slug text,
studio_id int,
studio_name text,
studio_slug text,
entity_ids multi,
actor_ids multi,
actors text,
actor_count int,
female_count int,
male_count int,
trans_count int,
unidentified_count int,
tag_ids multi,
assigned_tag_ids multi64,
tags text,
movie_ids multi,
movies text,
serie_ids multi,
series text,
meta text,
date bigint,
fingerprints text,
is_showcased bool,
created_at bigint,
effective_date bigint,
stashed int,
dupe_index int
)`);
await utilsApi.sql('drop table if exists scenes_tags');
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
)`);
*/
/* 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...');
console.log('Recreated scenes tables, syncing scenes...');
await syncManticoreScenes();
}
knex.destroy();
await syncManticoreScenes();
}
init();
if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildScenes();
}
});
}
+5 -5
View File
@@ -1,8 +1,8 @@
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js';
import { syncStashes } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() {
export async function rebuildStashes() {
await utilsApi.sql('drop table if exists scenes_stashed');
await utilsApi.sql(`create table if not exists scenes_stashed (
@@ -35,8 +35,8 @@ async function init() {
await syncStashes('scene');
await syncStashes('actor');
await syncStashes('movie');
knex.destroy();
}
init();
if (import.meta.main) {
runTool(rebuildStashes);
}
+19
View File
@@ -0,0 +1,19 @@
import process from 'node:process';
import { knexOwner as knex } from '../src/knex.js';
import redis from '../src/redis.js';
// runs a command line tool and closes the connections afterwards, the knex pool and redis would otherwise keep the process alive
export default async function runTool(tool) {
try {
await tool();
await knex.destroy();
await redis.quit();
}
catch (error) {
// the manticore client rejects with a plain response object rather than an Error, print the server's message
console.error(error instanceof Error ? error : error?.body?.error || error?.body || error);
process.exit(1);
}
}
+16
View File
@@ -0,0 +1,16 @@
import { rebuildActors } from './manticore-actors.js';
import { rebuildMovies } from './manticore-movies.js';
import { rebuildScenes } from './manticore-scenes.js';
import { rebuildStashes } from './manticore-stashes.js';
import runTool from './run-tool.js';
// recreates and fills every manticore table from postgres, i.e. after a manticore upgrade or on a fresh data directory
runTool(async () => {
// stashes first, the scenes sync also writes scene stashes and fails if their table doesn't exist yet
await rebuildStashes();
await rebuildScenes();
await rebuildMovies();
await rebuildActors();
console.log('Rebuilt all manticore tables');
});
+56
View File
@@ -0,0 +1,56 @@
const numberPattern = /^\d+$/;
const letterPattern = /^[a-z]$/i;
// ranges: 3 is exactly 3, 2- is at least 2, -4 is at most 4, 2-4 is between 2 and 4 inclusive
// comma is accepted as a legacy separator for closed ranges, e.g. age=22,30 from older links
// values not matching the pattern invalidate the range, which keeps them safe to use in queries
export function parseRange(rangeString, { pattern = numberPattern, parse = Number } = {}) {
const parts = String(rangeString ?? '').trim().split(/[-,]/);
if (parts.length > 2 || parts.every((part) => part === '') || parts.some((part) => part !== '' && !pattern.test(part))) {
return null;
}
const [minString, maxString = minString] = parts; // no separator means an exact value
return {
min: minString ? parse(minString) : null,
max: maxString ? parse(maxString) : null,
};
}
// single letter cup sizes, matching the cup filter's regex character class
export function parseLetterRange(rangeString) {
return parseRange(rangeString, {
pattern: letterPattern,
parse: (letter) => letter.toUpperCase(),
});
}
export function formatRange(range) {
if (!range || (range.min === null && range.max === null)) {
return undefined;
}
if (range.min === range.max) {
return String(range.min);
}
return `${range.min ?? ''}-${range.max ?? ''}`;
}
// years are a range like 2015-2020 or 2020-, or a list like 2015,2019 from older links
export function parseYears(yearsString) {
if (yearsString?.includes('-')) {
return { years: [], yearRange: parseRange(yearsString) };
}
return {
years: yearsString?.split(',').map((year) => Number(year)).filter(Boolean) || [],
yearRange: null,
};
}
export function formatYears({ years, yearRange }) {
return formatRange(yearRange) || years?.filter(Boolean).join(',') || undefined;
}