Fixed movie scene photo query, added caps.

This commit is contained in:
DebaucheryLibrarian 2024-08-23 02:17:59 +02:00
parent b3a3562bb8
commit 8e473d5e3e
2 changed files with 32 additions and 9 deletions

View File

@ -28,12 +28,12 @@
</div> </div>
<div <div
v-if="movie.photos.length > 0" v-if="movie.photos.length > 0 || movie.caps.length > 0"
class="album" class="album"
:class="{ single: movie.photos.length === 1 }" :class="{ single: (movie.photos.length + movie.caps.length) === 1 }"
> >
<div <div
v-for="photo in movie.photos" v-for="photo in movie.photos.concat(movie.caps)"
:key="`photo-${photo.id}`" :key="`photo-${photo.id}`"
class="photo-container" class="photo-container"
> >

View File

@ -56,6 +56,7 @@ function curateMovie(rawMovie, assets) {
// poster: curateMedia(assets.poster), // poster: curateMedia(assets.poster),
covers: assets.covers.map((cover) => curateMedia(cover)), covers: assets.covers.map((cover) => curateMedia(cover)),
photos: assets.photos.map((photo) => curateMedia(photo)), photos: assets.photos.map((photo) => curateMedia(photo)),
caps: assets.caps.map((cap) => curateMedia(cap)),
trailer: curateMedia(assets.trailer), trailer: curateMedia(assets.trailer),
stashes: assets.stashes?.map((stash) => curateStash(stash)) || [], stashes: assets.stashes?.map((stash) => curateStash(stash)) || [],
createdBatchId: rawMovie.created_batch_id, createdBatchId: rawMovie.created_batch_id,
@ -73,6 +74,7 @@ export async function fetchMoviesById(movieIds, reqUser) {
sceneTags, sceneTags,
covers, covers,
photos, photos,
caps,
trailers, trailers,
stashes, stashes,
} = await promiseProps({ } = await promiseProps({
@ -124,11 +126,30 @@ export async function fetchMoviesById(movieIds, reqUser) {
.whereIn('movie_id', movieIds) .whereIn('movie_id', movieIds)
.leftJoin('media', 'media.id', 'movies_covers.media_id') .leftJoin('media', 'media.id', 'movies_covers.media_id')
.orderBy('media.index'), .orderBy('media.index'),
photos: knex('movies') photos: knex.transaction(async (trx) => {
.whereIn('movies.id', movieIds) if (reqUser) {
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id') await trx.select(knex.raw('set_config(\'user.id\', :userId, true)', { userId: reqUser.id }));
}
return trx('movies_scenes')
.select('media.*', 'movies_scenes.movie_id')
.whereIn('movies_scenes.movie_id', movieIds)
.whereNotNull('media.id')
.leftJoin('releases_photos', 'releases_photos.release_id', 'movies_scenes.scene_id') .leftJoin('releases_photos', 'releases_photos.release_id', 'movies_scenes.scene_id')
.leftJoin('media', 'media.id', 'releases_photos.media_id'), .leftJoin('media', 'media.id', 'releases_photos.media_id');
}),
caps: knex.transaction(async (trx) => {
if (reqUser) {
await trx.select(knex.raw('set_config(\'user.id\', :userId, true)', { userId: reqUser.id }));
}
return trx('movies_scenes')
.select('media.*', 'movies_scenes.movie_id')
.whereIn('movies_scenes.movie_id', movieIds)
.whereNotNull('media.id')
.leftJoin('releases_caps', 'releases_caps.release_id', 'movies_scenes.scene_id')
.leftJoin('media', 'media.id', 'releases_caps.media_id');
}),
trailers: knex('movies_trailers') trailers: knex('movies_trailers')
.whereIn('movie_id', movieIds) .whereIn('movie_id', movieIds)
.leftJoin('media', 'media.id', 'movies_trailers.media_id'), .leftJoin('media', 'media.id', 'movies_trailers.media_id'),
@ -154,7 +175,8 @@ export async function fetchMoviesById(movieIds, reqUser) {
const movieTags = tags.filter((tag) => tag.movie_id === movieId); const movieTags = tags.filter((tag) => tag.movie_id === movieId);
const movieSceneTags = sceneTags.filter((tag) => tag.movie_id === movieId); const movieSceneTags = sceneTags.filter((tag) => tag.movie_id === movieId);
const movieCovers = covers.filter((cover) => cover.movie_id === movieId); const movieCovers = covers.filter((cover) => cover.movie_id === movieId);
const moviePhotos = photos.filter((photo) => photo.release_id === movieId); const moviePhotos = photos.filter((photo) => photo.movie_id === movieId);
const movieCaps = caps.filter((cap) => cap.movie_id === movieId);
const movieTrailer = trailers.find((trailer) => trailer.movie_id === movieId); const movieTrailer = trailers.find((trailer) => trailer.movie_id === movieId);
const movieStashes = stashes.filter((stash) => stash.movie_id === movieId); const movieStashes = stashes.filter((stash) => stash.movie_id === movieId);
@ -167,6 +189,7 @@ export async function fetchMoviesById(movieIds, reqUser) {
tags: combinedTags, tags: combinedTags,
covers: movieCovers, covers: movieCovers,
photos: moviePhotos, photos: moviePhotos,
caps: movieCaps,
trailer: movieTrailer, trailer: movieTrailer,
stashes: movieStashes, stashes: movieStashes,
}); });