diff --git a/components/media/banner.vue b/components/media/banner.vue index 77c9046..20236c4 100644 --- a/components/media/banner.vue +++ b/components/media/banner.vue @@ -49,12 +49,12 @@
diff --git a/components/scenes/chapters.vue b/components/scenes/chapters.vue new file mode 100755 index 0000000..03ec5ae --- /dev/null +++ b/components/scenes/chapters.vue @@ -0,0 +1,239 @@ + + + + + diff --git a/pages/scene/+Page.vue b/pages/scene/+Page.vue index 242cb37..e0b16e5 100644 --- a/pages/scene/+Page.vue +++ b/pages/scene/+Page.vue @@ -168,6 +168,12 @@
+ +
({ + 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,