Using media database for images.
This commit is contained in:
@@ -3,15 +3,19 @@
|
||||
const knex = require('./knex');
|
||||
|
||||
async function curateRelease(release) {
|
||||
const actors = await knex('actors_associated')
|
||||
.select('actors.id', 'actors.name', 'actors.gender')
|
||||
.where({ release_id: release.id })
|
||||
.leftJoin('actors', 'actors.id', 'actors_associated.actor_id');
|
||||
|
||||
const tags = await knex('tags_associated')
|
||||
.select('tags.tag', 'tags.capitalization')
|
||||
.where({ release_id: release.id })
|
||||
.leftJoin('tags', 'tags.tag', 'tags_associated.tag_id');
|
||||
const [actors, tags, media] = await Promise.all([
|
||||
knex('actors_associated')
|
||||
.select('actors.id', 'actors.name', 'actors.gender', 'actors.slug')
|
||||
.where({ release_id: release.id })
|
||||
.leftJoin('actors', 'actors.id', 'actors_associated.actor_id'),
|
||||
knex('tags_associated')
|
||||
.select('tags.tag', 'tags.slug')
|
||||
.where({ release_id: release.id })
|
||||
.leftJoin('tags', 'tags.id', 'tags_associated.tag_id'),
|
||||
knex('media')
|
||||
.where({ target_id: release.id })
|
||||
.orderBy('role'),
|
||||
]);
|
||||
|
||||
return {
|
||||
id: release.id,
|
||||
@@ -24,7 +28,7 @@ async function curateRelease(release) {
|
||||
actors,
|
||||
director: release.director,
|
||||
tags,
|
||||
photos: release.photos,
|
||||
photos: media,
|
||||
rating: {
|
||||
likes: release.likes,
|
||||
dislikes: release.dislikes,
|
||||
@@ -58,8 +62,6 @@ async function fetchReleases(releaseId) {
|
||||
.orderBy('date', 'desc')
|
||||
.limit(100);
|
||||
|
||||
// console.log(curateReleases(releases));
|
||||
|
||||
return curateReleases(releases);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user