Showing movie trailers. Added internal parameter for entity visibility.
This commit is contained in:
@@ -67,6 +67,10 @@ export async function fetchEntities(options) {
|
||||
if (options.type) {
|
||||
builder.where('entities.type', options.type);
|
||||
}
|
||||
|
||||
if (options.showInvisible !== true) {
|
||||
builder.where('entities.visible', true);
|
||||
}
|
||||
})
|
||||
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||
.orderBy(...(options.order || ['name', 'asc']))
|
||||
|
||||
@@ -55,6 +55,7 @@ function curateMovie(rawMovie, assets) {
|
||||
// poster: curateMedia(assets.poster),
|
||||
covers: assets.covers.map((cover) => curateMedia(cover)),
|
||||
photos: assets.photos.map((photo) => curateMedia(photo)),
|
||||
trailer: curateMedia(assets.trailer),
|
||||
stashes: assets.stashes?.map((stash) => curateStash(stash)) || [],
|
||||
createdBatchId: rawMovie.created_batch_id,
|
||||
updatedBatchId: rawMovie.updated_batch_id,
|
||||
@@ -68,8 +69,10 @@ export async function fetchMoviesById(movieIds, reqUser) {
|
||||
actors,
|
||||
directors,
|
||||
tags,
|
||||
sceneTags,
|
||||
covers,
|
||||
photos,
|
||||
trailers,
|
||||
stashes,
|
||||
} = await promiseProps({
|
||||
movies: knex('movies')
|
||||
@@ -103,7 +106,11 @@ export async function fetchMoviesById(movieIds, reqUser) {
|
||||
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id')
|
||||
.leftJoin('releases_directors', 'releases_directors.release_id', 'movies_scenes.scene_id')
|
||||
.leftJoin('actors as directors', 'directors.id', 'releases_directors.director_id'),
|
||||
tags: knex('movies')
|
||||
tags: knex('movies_tags')
|
||||
.whereIn('movie_id', movieIds)
|
||||
.whereNotNull('tags.id')
|
||||
.leftJoin('tags', 'tags.id', 'movies_tags.tag_id'),
|
||||
sceneTags: knex('movies')
|
||||
.select('tags.id', 'tags.slug', 'tags.name', 'tags.priority', 'movies.id as movie_id')
|
||||
.distinct()
|
||||
.whereIn('movies.id', movieIds)
|
||||
@@ -121,6 +128,9 @@ export async function fetchMoviesById(movieIds, reqUser) {
|
||||
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id')
|
||||
.leftJoin('releases_photos', 'releases_photos.release_id', 'movies_scenes.scene_id')
|
||||
.leftJoin('media', 'media.id', 'releases_photos.media_id'),
|
||||
trailers: knex('movies_trailers')
|
||||
.whereIn('movie_id', movieIds)
|
||||
.leftJoin('media', 'media.id', 'movies_trailers.media_id'),
|
||||
stashes: reqUser
|
||||
? knexOwner('stashes_movies')
|
||||
.leftJoin('stashes', 'stashes.id', 'stashes_movies.stash_id')
|
||||
@@ -141,17 +151,22 @@ export async function fetchMoviesById(movieIds, reqUser) {
|
||||
const movieActors = actors.filter((actor) => actor.movie_id === movieId);
|
||||
const movieDirectors = directors.filter((director) => director.release_id === movieId);
|
||||
const movieTags = tags.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 moviePhotos = photos.filter((photo) => photo.release_id === movieId);
|
||||
const movieTrailer = trailers.find((trailer) => trailer.movie_id === movieId);
|
||||
const movieStashes = stashes.filter((stash) => stash.movie_id === movieId);
|
||||
|
||||
const combinedTags = Object.values(Object.fromEntries(movieTags.concat(movieSceneTags).map((tag) => [tag.slug, tag]))).toSorted((tagA, tagB) => tagB.priority - tagA.priority);
|
||||
|
||||
return curateMovie(movie, {
|
||||
channel: movieChannel,
|
||||
actors: movieActors,
|
||||
directors: movieDirectors,
|
||||
tags: movieTags,
|
||||
tags: combinedTags,
|
||||
covers: movieCovers,
|
||||
photos: moviePhotos,
|
||||
trailer: movieTrailer,
|
||||
stashes: movieStashes,
|
||||
});
|
||||
}).filter(Boolean);
|
||||
|
||||
Reference in New Issue
Block a user