Refactored clips into chapters.
This commit is contained in:
@@ -45,6 +45,14 @@ function curateRelease(release, withMedia = false, withPoster = true) {
|
||||
name: tag.name,
|
||||
slug: tag.slug,
|
||||
})),
|
||||
chapters: (release.chapters || []).map(chapter => ({
|
||||
id: chapter.id,
|
||||
index: chapter.index,
|
||||
time: chapter.time,
|
||||
duration: chapter.duration,
|
||||
title: chapter.title,
|
||||
description: chapter.description,
|
||||
})),
|
||||
...((withMedia || withPoster) && {
|
||||
poster: release.poster ? {
|
||||
id: release.poster.id,
|
||||
@@ -80,7 +88,8 @@ function withRelations(queryBuilder, withMedia = false, withPoster = true) {
|
||||
row_to_json(entities) as entity,
|
||||
row_to_json(parents) as parent,
|
||||
COALESCE(json_agg(DISTINCT actors) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
||||
COALESCE(json_agg(DISTINCT tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags
|
||||
COALESCE(json_agg(DISTINCT tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(json_agg(DISTINCT chapters) FILTER (WHERE chapters.id IS NOT NULL), '[]') as chapters
|
||||
`))
|
||||
.leftJoin('entities', 'entities.id', 'releases.entity_id')
|
||||
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||
@@ -88,6 +97,7 @@ function withRelations(queryBuilder, withMedia = false, withPoster = true) {
|
||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
|
||||
.leftJoin('releases_tags', 'releases_tags.release_id', 'releases.id')
|
||||
.leftJoin('tags', 'tags.id', 'releases_tags.tag_id')
|
||||
.leftJoin('chapters', 'chapters.release_id', 'releases.id')
|
||||
.groupBy(knex.raw(`
|
||||
releases.id, releases.entry_id, releases.shoot_id, releases.title, releases.url, releases.date, releases.description, releases.duration, releases.created_at,
|
||||
entities.id, parents.id
|
||||
@@ -166,10 +176,6 @@ async function deleteScenes(sceneIds) {
|
||||
}
|
||||
|
||||
// there can be too many scene IDs for where in, causing a stack depth error
|
||||
await knex('movies_scenes')
|
||||
.whereRaw('scene_id = ANY(:sceneIds)', { sceneIds })
|
||||
.delete();
|
||||
|
||||
const deleteCount = await knex('releases')
|
||||
.whereRaw('id = ANY(:sceneIds)', { sceneIds })
|
||||
.delete();
|
||||
|
||||
Reference in New Issue
Block a user