Fixed Whale Member posters and photos.

This commit is contained in:
2020-05-20 02:23:45 +02:00
parent b6691e1991
commit b1b7cd6d50
4 changed files with 26 additions and 11 deletions

View File

@@ -67,7 +67,7 @@ function withRelations(queryBuilder, withMedia = false, type = 'scene') {
row_to_json(sites) as site,
row_to_json(networks) as network,
row_to_json(site_networks) as site_network,
json_agg(DISTINCT actors) as actors
COALESCE(json_agg(DISTINCT actors) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors
`))
.where('type', type)
.leftJoin('sites', 'sites.id', 'releases.site_id')
@@ -84,7 +84,7 @@ function withRelations(queryBuilder, withMedia = false, type = 'scene') {
queryBuilder
.select(knex.raw(`
row_to_json(posters) as poster,
json_agg(DISTINCT photos) as photos
COALESCE(json_agg(DISTINCT photos) FILTER (WHERE photos.id IS NOT NULL), '[]') as photos
`))
.leftJoin('releases_posters', 'releases_posters.release_id', 'releases.id')
.leftJoin('media as posters', 'posters.id', 'releases_posters.media_id')