Removed type property from scenes API.

This commit is contained in:
DebaucheryLibrarian
2020-08-13 16:10:58 +02:00
parent f8c9b69f4b
commit 59e2124407
5 changed files with 86 additions and 16 deletions

View File

@@ -61,7 +61,7 @@ function curateRelease(release, withMedia = false) {
};
}
function withRelations(queryBuilder, withMedia = false, type = 'scene') {
function withRelations(queryBuilder, withMedia = false) {
queryBuilder
.select(knex.raw(`
releases.id, releases.entry_id, releases.shoot_id, releases.title, releases.url, releases.date, releases.description, releases.duration, releases.created_at,
@@ -70,7 +70,6 @@ function withRelations(queryBuilder, withMedia = false, type = 'scene') {
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
`))
.where('releases.type', type)
.leftJoin('entities', 'entities.id', 'releases.entity_id')
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
.leftJoin('releases_actors', 'releases_actors.release_id', 'releases.id')
@@ -96,27 +95,27 @@ function withRelations(queryBuilder, withMedia = false, type = 'scene') {
}
}
async function fetchRelease(releaseId, type = 'scene') {
async function fetchRelease(releaseId) {
const release = await knex('releases')
.where('releases.id', releaseId)
.modify(withRelations, true, type)
.modify(withRelations, true)
.first();
return curateRelease(release, true);
}
async function fetchReleases(limit = 100, type = 'scene') {
async function fetchReleases(limit = 100) {
const releases = await knex('releases')
.modify(withRelations, false, type)
.modify(withRelations, false)
.limit(Math.min(limit, 1000));
return releases.map(release => curateRelease(release));
}
async function searchReleases(query, limit = 100, type = 'scene') {
async function searchReleases(query, limit = 100) {
const releases = await knex
.from(knex.raw('search_releases(?) as releases', [query]))
.modify(withRelations, false, type)
.modify(withRelations, false)
.limit(Math.min(limit, 1000));
return releases.map(release => curateRelease(release));