Showing chapter information.
This commit is contained in:
@@ -58,6 +58,8 @@ function curateScene(rawScene, assets) {
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log(assets.chapters);
|
||||
|
||||
const curatedScene = {
|
||||
id: rawScene.id,
|
||||
title: rawScene.title,
|
||||
@@ -113,6 +115,18 @@ function curateScene(rawScene, assets) {
|
||||
name: tag.name,
|
||||
priority: tag.priority,
|
||||
})),
|
||||
chapters: assets.chapters.map((chapter) => ({
|
||||
id: chapter.id,
|
||||
title: chapter.title,
|
||||
time: chapter.time,
|
||||
duration: chapter.duration,
|
||||
poster: curateMedia(chapter.chapter_poster),
|
||||
tags: chapter.chapter_tags.map((tag) => ({
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
slug: tag.slug,
|
||||
})),
|
||||
})),
|
||||
qualities: rawScene.qualities?.sort((qualityA, qualityB) => qualityB - qualityA) || [],
|
||||
photoCount: rawScene.photo_count,
|
||||
movies: assets.movies.map((movie) => ({
|
||||
@@ -151,6 +165,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
actors,
|
||||
directors,
|
||||
tags,
|
||||
chapters,
|
||||
movies,
|
||||
series,
|
||||
posters,
|
||||
@@ -202,6 +217,19 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
.whereNotNull('tags.id')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.orderBy('priority', 'desc'),
|
||||
chapters: knex('chapters')
|
||||
.select(
|
||||
'chapters.*',
|
||||
knex.raw('coalesce(json_agg(tags) filter (where tags.id is not null), \'[]\') as chapter_tags'),
|
||||
knex.raw('row_to_json(posters) as chapter_poster'),
|
||||
)
|
||||
.leftJoin('chapters_tags', 'chapters_tags.chapter_id', 'chapters.id')
|
||||
.leftJoin('tags', 'tags.id', 'chapters_tags.tag_id')
|
||||
.leftJoin('chapters_posters', 'chapters_posters.chapter_id', 'chapters.id')
|
||||
.leftJoin('media as posters', 'posters.id', 'chapters_posters.media_id')
|
||||
.whereIn('chapters.release_id', sceneIds)
|
||||
.groupBy('chapters.id', 'posters.id')
|
||||
.orderBy('time', 'asc'),
|
||||
movies: context.includePartOf ? knex('movies_scenes')
|
||||
.select('movies_scenes.scene_id', 'movies.*', knex.raw('json_agg(media) as movie_covers'))
|
||||
.leftJoin('movies', 'movies.id', 'movies_scenes.movie_id')
|
||||
@@ -289,6 +317,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
const sceneActors = actors.filter((actor) => actor.release_id === sceneId);
|
||||
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);
|
||||
const sceneMovies = movies.filter((movie) => movie.scene_id === sceneId);
|
||||
const sceneSeries = series.filter((serie) => serie.scene_id === sceneId);
|
||||
const scenePoster = posters.find((poster) => poster.release_id === sceneId);
|
||||
@@ -305,6 +334,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
actors: sceneActors,
|
||||
directors: sceneDirectors,
|
||||
tags: sceneTags,
|
||||
chapters: sceneChapters,
|
||||
movies: sceneMovies,
|
||||
series: sceneSeries,
|
||||
poster: scenePoster,
|
||||
|
||||
Reference in New Issue
Block a user