Showing quality on scene page.

This commit is contained in:
DebaucheryLibrarian 2024-06-04 04:46:38 +02:00
parent 7fe3f63a5c
commit 78cb842cf7
3 changed files with 33 additions and 171 deletions

View File

@ -63,13 +63,14 @@
<Link
:href="scene.url"
:title="scene.effectiveDate.toISOString()"
:title="scene.date ? format(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${format(scene.createdAt, 'y-MM-dd')}`"
target="_blank"
class="date-link nolink"
>
<time
:datetime="scene.effectiveDate.toISOString()"
class="date"
:class="{ nodate: !scene.date }"
>{{ format(scene.effectiveDate, 'MMM d, y') }}</time>
</Link>
</div>
@ -249,6 +250,11 @@ const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.id ===
align-items: center;
}
.nodate {
font-style: italic;
color: var(--highlight);
}
.row {
margin: 0 .5rem .25rem .5rem;
font-size: .9rem;

View File

@ -93,8 +93,10 @@
<Link
:href="scene.url"
:title="scene.date ? formatDate(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${formatDate(scene.createdAt, 'y-MM-dd')}`"
target="_blank"
class="date nolink"
:class="{ nodate: !scene.date }"
>
<time
:datetime="scene.effectiveDate.toISOString()"
@ -211,17 +213,9 @@
</div>
<div
v-if="scene.duration || scene.directors.length > 0 || scene.shootId"
v-if="scene.duration || scene.directors.length > 0 || scene.shootId || scene.qualities.length > 0"
class="section details"
>
<div
v-if="scene.duration"
class="detail"
>
<h3 class="heading">Duration</h3>
{{ formatDuration(scene.duration) }}
</div>
<div
v-if="scene.directors.length > 0"
class="detail"
@ -230,6 +224,14 @@
{{ scene.directors.map((director) => director.name).join(', ') }}
</div>
<div
v-if="scene.duration"
class="detail"
>
<h3 class="heading">Duration</h3>
{{ formatDuration(scene.duration) }}
</div>
<div
v-if="scene.shootId"
class="detail"
@ -237,6 +239,14 @@
<h3 class="heading">Shoot</h3>
{{ scene.shootId }}
</div>
<div
v-if="scene.qualities.length > 0"
class="detail"
>
<h3 class="heading">Quality</h3>
{{ scene.qualities.map((quality) => `${quality}p`).join(', ') }}
</div>
</div>
<div class="section details">
@ -533,6 +543,11 @@ function copySummary() {
font-weight: bold;
}
.nodate {
color: var(--highlight);
font-weight: normal;
}
.info,
.header {
border-top: none;
@ -647,7 +662,7 @@ function copySummary() {
.details {
display: flex;
gap: 1rem;
gap: 1rem 1.5rem;
}
.description {

View File

@ -74,6 +74,7 @@ function curateScene(rawScene, assets) {
slug: tag.slug,
name: tag.name,
})),
qualities: rawScene.qualities.sort((qualityA, qualityB) => qualityB - qualityA),
movies: assets.movies.map((movie) => ({
id: movie.id,
slug: movie.slug,
@ -263,160 +264,6 @@ function curateOptions(options) {
};
}
/*
function buildQuery(filters = {}, options) {
const query = {
bool: {
must: [],
},
};
let sort = [{ effective_date: 'desc' }];
if (!filters.scope || filters.scope === 'latest') {
query.bool.must.push({
range: {
effective_date: {
lte: Math.round(Date.now() / 1000),
},
},
});
}
if (filters.scope === 'upcoming') {
query.bool.must.push({
range: {
effective_date: {
gt: Math.round(Date.now() / 1000),
},
},
});
sort = [{ effective_date: 'asc' }];
}
if (filters.scope === 'new') {
sort = [{ created_at: 'desc' }, { effective_date: 'asc' }];
}
if (filters.scope === 'likes') {
sort = [{ stashed: 'desc' }, { effective_date: 'desc' }];
}
if (filters.scope === 'results') {
sort = [{ _score: 'desc' }, { effective_date: 'desc' }];
}
if (filters.query) {
query.bool.must.push({ match: { '!title': filters.query } }); // title_filtered is matched instead of title
}
if (filters.tagIds) {
filters.tagIds.forEach((tagId) => {
query.bool.must.push({ equals: { 'any(tag_ids)': tagId } });
});
}
if (filters.entityId) {
query.bool.must.push({
bool: {
should: [
{ equals: { channel_id: filters.entityId } },
{ equals: { network_id: filters.entityId } },
],
},
});
}
if (filters.actorIds) {
filters.actorIds.forEach((actorId) => {
query.bool.must.push({ equals: { 'any(actor_ids)': actorId } });
});
}
if (filters.stashId && options.index === 'scenes_stashed') {
query.bool.must.push({ equals: { stash_id: filters.stashId } });
}
return { query, sort };
}
function buildAggregates(options) {
const aggregates = {};
if (options.aggregateActors) {
aggregates.actorIds = {
terms: {
field: 'actor_ids',
size: config.database.manticore.maxAggregateSize,
},
sort: [{ 'count(*)': { order: 'desc' } }],
};
}
if (options.aggregateTags) {
aggregates.tagIds = {
terms: {
field: 'tag_ids',
size: config.database.manticore.maxAggregateSize,
},
sort: [{ 'count(*)': { order: 'desc' } }],
};
}
if (options.aggregateChannels) {
aggregates.channelIds = {
terms: {
field: 'channel_id',
size: config.database.manticore.maxAggregateSize,
},
sort: [{ 'count(*)': { order: 'desc' } }],
};
}
return aggregates;
}
async function queryManticoreJson(filters, options, _reqUser) {
const { query, sort } = buildQuery(filters, options);
const result = await searchApi.search({
index: options.index,
query,
limit: options.limit,
offset: (options.page - 1) * options.limit,
sort,
aggs: buildAggregates(options),
options: {
max_matches: config.database.manticore.maxMatches,
max_query_time: config.database.manticore.maxQueryTime,
field_weights: {
title_filtered: 7,
actors: 10,
tags: 9,
meta: 6,
channel_name: 2,
channel_slug: 3,
network_name: 1,
network_slug: 1,
},
},
});
const scenes = result.hits.hits.map((hit) => ({
id: hit._id,
...hit._source,
_score: hit._score,
}));
return {
scenes,
total: result.hits.total,
aggregations: result.aggregations && Object.fromEntries(Object.entries(result.aggregations).map(([key, { buckets }]) => [key, buckets])),
};
}
*/
async function queryManticoreSql(filters, options, _reqUser) {
const aggSize = config.database.manticore.maxAggregateSize;
@ -613,12 +460,6 @@ export async function fetchScenes(filters, rawOptions, reqUser) {
console.log('filters', filters);
console.log('options', options);
/*
const result = config.database.manticore.forceSql || filters.stashId
? await queryManticoreSql(filters, options, reqUser)
: await queryManticoreJson(filters, options, reqUser);
*/
console.time('manticore sql');
const result = await queryManticoreSql(filters, options, reqUser);
console.timeEnd('manticore sql');