Added trailers. Improved scene page scaling.
This commit is contained in:
@@ -71,7 +71,7 @@ export function sortActorsByGender(actors, context = {}) {
|
||||
}
|
||||
|
||||
const alphaActors = actors.sort((actorA, actorB) => actorA.name.localeCompare(actorB.name, 'en'));
|
||||
const genderActors = ['transsexual', 'female', 'male', undefined, null, 'male'].flatMap((gender) => alphaActors.filter((actor) => actor.gender === gender));
|
||||
const genderActors = ['transsexual', 'female', undefined, null, 'male'].flatMap((gender) => alphaActors.filter((actor) => actor.gender === gender));
|
||||
|
||||
const titleSlug = slugify(context.title);
|
||||
const titleActors = titleSlug ? genderActors.sort((actorA, actorB) => {
|
||||
@@ -344,7 +344,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
actors.gender as gender,
|
||||
actors.country as country,
|
||||
actors.height as height,
|
||||
actors.weight as weight,
|
||||
actors.mass as mass,
|
||||
actors.cup as cup,
|
||||
actors.natural_boobs as natural_boobs,
|
||||
actors.date_of_birth as date_of_birth,
|
||||
@@ -352,16 +352,15 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
actors.scenes as scenes,
|
||||
actors.stashed as stashed,
|
||||
created_at as stashed_at,
|
||||
if(actors.date_of_birth, floor((now() - actors.date_of_birth) / 31556952), 0) as age
|
||||
if(actors.date_of_birth, floor((now() - actors.date_of_birth) / 31556952), 0) as age,
|
||||
weight() as _score
|
||||
`));
|
||||
// weight() as _score
|
||||
|
||||
builder
|
||||
.innerJoin('actors', 'actors.id', 'actors_stashed.actor_id')
|
||||
.where('stash_id', filters.stashId);
|
||||
} else {
|
||||
// builder.select(knex.raw('*, weight() as _score'));
|
||||
builder.select(knex.raw('*'));
|
||||
builder.select(knex.raw('*, weight() as _score'));
|
||||
}
|
||||
|
||||
if (filters.query) {
|
||||
@@ -374,7 +373,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
}
|
||||
});
|
||||
|
||||
['age', 'height', 'weight'].forEach((attribute) => {
|
||||
['age', 'height'].forEach((attribute) => {
|
||||
if (filters[attribute]) {
|
||||
builder
|
||||
.where(attribute, '>=', filters[attribute][0])
|
||||
@@ -382,6 +381,13 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
}
|
||||
});
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -420,6 +426,11 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
{ column: 'actors.scenes', order: options.order[1] },
|
||||
{ column: 'actors.slug', order: 'asc' },
|
||||
]);
|
||||
} else if (options.order?.[0] === 'results') {
|
||||
builder.orderBy([
|
||||
{ column: 'actors._score', order: options.order[1] },
|
||||
{ column: 'actors.slug', order: 'asc' },
|
||||
]);
|
||||
} else if (options.order?.[0] === 'stashed' && filters.stashId) {
|
||||
builder.orderBy([
|
||||
{ column: 'stashed_at', order: options.order[1] },
|
||||
|
||||
49
src/get-path.js
Normal file
49
src/get-path.js
Normal file
@@ -0,0 +1,49 @@
|
||||
// import config from 'config';
|
||||
import { pageContext } from '../renderer/usePageContext.js';
|
||||
|
||||
function getBasePath(media, type, options) {
|
||||
/*
|
||||
if (store.state.ui.sfw) {
|
||||
return config.media.assetPath;
|
||||
}
|
||||
*/
|
||||
|
||||
if (media.isS3) {
|
||||
return options.s3Path;
|
||||
}
|
||||
|
||||
if (options?.local) {
|
||||
return options.assetPath;
|
||||
}
|
||||
|
||||
return options.mediaPath;
|
||||
}
|
||||
|
||||
function getFilename(media, type, options) {
|
||||
/*
|
||||
if (store.state.ui.sfw && type && !options?.original) {
|
||||
return media.sfw[type];
|
||||
}
|
||||
|
||||
if (store.state.ui.sfw) {
|
||||
return media.sfw.path;
|
||||
}
|
||||
*/
|
||||
|
||||
if (type && !options?.original) {
|
||||
return media[type];
|
||||
}
|
||||
|
||||
return media.path;
|
||||
}
|
||||
|
||||
export default function getPath(media, type, options) {
|
||||
if (!media) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const path = getBasePath(media, type, { ...pageContext.env.media, ...options });
|
||||
const filename = getFilename(media, type, { ...pageContext.env.media, ...options });
|
||||
|
||||
return `${path}/${filename}`;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import config from 'config';
|
||||
import util from 'util'; /* eslint-disable-line no-unused-vars */
|
||||
|
||||
import { knexOwner as knex, knexManticore } from './knex.js';
|
||||
import { knexQuery as knex, knexOwner, knexManticore } from './knex.js';
|
||||
import { utilsApi } from './manticore.js';
|
||||
import { HttpError } from './errors.js';
|
||||
import { fetchActorsById, curateActor, sortActorsByGender } from './actors.js';
|
||||
@@ -20,6 +20,7 @@ function curateMedia(media) {
|
||||
path: media.path,
|
||||
thumbnail: media.thumbnail,
|
||||
lazy: media.lazy,
|
||||
hash: media.hash,
|
||||
isS3: media.is_s3,
|
||||
width: media.width,
|
||||
height: media.height,
|
||||
@@ -41,6 +42,7 @@ function curateScene(rawScene, assets) {
|
||||
effectiveDate: rawScene.effective_date,
|
||||
description: rawScene.description,
|
||||
duration: rawScene.duration,
|
||||
shootId: rawScene.shoot_id,
|
||||
channel: {
|
||||
id: assets.channel.id,
|
||||
slug: assets.channel.slug,
|
||||
@@ -71,6 +73,8 @@ function curateScene(rawScene, assets) {
|
||||
name: tag.name,
|
||||
})),
|
||||
poster: curateMedia(assets.poster),
|
||||
trailer: curateMedia(assets.trailer),
|
||||
teaser: curateMedia(assets.teaser),
|
||||
photos: assets.photos.map((photo) => curateMedia(photo)),
|
||||
stashes: assets.stashes?.map((stash) => curateStash(stash)) || [],
|
||||
createdBatchId: rawScene.created_batch_id,
|
||||
@@ -88,6 +92,8 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
tags,
|
||||
posters,
|
||||
photos,
|
||||
trailers,
|
||||
teasers,
|
||||
stashes,
|
||||
lastBatch: { id: lastBatchId },
|
||||
} = await promiseProps({
|
||||
@@ -119,16 +125,40 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
posters: knex('releases_posters')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('media', 'media.id', 'releases_posters.media_id'),
|
||||
photos: knex('releases_photos')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('media', 'media.id', 'releases_photos.media_id'),
|
||||
photos: knex.transaction(async (trx) => {
|
||||
if (reqUser) {
|
||||
await trx.select(knex.raw('set_config(\'user.id\', :userId, true)', { userId: reqUser.id }));
|
||||
}
|
||||
|
||||
return trx('releases_photos')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('media', 'media.id', 'releases_photos.media_id');
|
||||
}),
|
||||
trailers: knex.transaction(async (trx) => {
|
||||
if (reqUser) {
|
||||
await trx.select(knex.raw('set_config(\'user.id\', :userId, true)', { userId: reqUser.id }));
|
||||
}
|
||||
|
||||
return trx('releases_trailers')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('media', 'media.id', 'releases_trailers.media_id');
|
||||
}),
|
||||
teasers: knex.transaction(async (trx) => {
|
||||
if (reqUser) {
|
||||
await trx.select(knex.raw('set_config(\'user.id\', :userId, true)', { userId: reqUser.id }));
|
||||
}
|
||||
|
||||
return trx('releases_teasers')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('media', 'media.id', 'releases_teasers.media_id');
|
||||
}),
|
||||
lastBatch: knex('batches')
|
||||
.select('id')
|
||||
.where('showcased', true)
|
||||
.orderBy('created_at', 'desc')
|
||||
.first(),
|
||||
stashes: reqUser
|
||||
? knex('stashes_scenes')
|
||||
? knexOwner('stashes_scenes')
|
||||
.leftJoin('stashes', 'stashes.id', 'stashes_scenes.stash_id')
|
||||
.where('stashes.user_id', reqUser.id)
|
||||
.whereIn('stashes_scenes.scene_id', sceneIds)
|
||||
@@ -155,9 +185,13 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
const sceneTags = tags.filter((tag) => tag.release_id === sceneId);
|
||||
const scenePoster = posters.find((poster) => poster.release_id === sceneId);
|
||||
const scenePhotos = photos.filter((photo) => photo.release_id === sceneId);
|
||||
const sceneTrailers = trailers.find((trailer) => trailer.release_id === sceneId);
|
||||
const sceneTeasers = teasers.find((teaser) => teaser.release_id === sceneId);
|
||||
const sceneStashes = stashes.filter((stash) => stash.scene_id === sceneId);
|
||||
const sceneActorStashes = sceneActors.map((actor) => actorStashes.find((stash) => stash.actor_id === actor.id)).filter(Boolean);
|
||||
|
||||
console.log(sceneActors);
|
||||
|
||||
return curateScene(scene, {
|
||||
channel: sceneChannel,
|
||||
actors: sceneActors,
|
||||
@@ -165,6 +199,8 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
tags: sceneTags,
|
||||
poster: scenePoster,
|
||||
photos: scenePhotos,
|
||||
trailer: sceneTrailers,
|
||||
teaser: sceneTeasers,
|
||||
stashes: sceneStashes,
|
||||
actorStashes: sceneActorStashes,
|
||||
lastBatchId,
|
||||
|
||||
@@ -137,6 +137,7 @@ export default async function initServer() {
|
||||
allowSignup: config.auth.signup,
|
||||
maxMatches: config.database.manticore.maxMatches,
|
||||
maxAggregateSize: config.database.manticore.maxAggregateSize,
|
||||
media: config.media,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user