Using batch insert for profiles to prevent errors on large inserts.
This commit is contained in:
@@ -35,8 +35,11 @@ function curateRelease(release, withMedia = false) {
|
||||
gender: actor.gender,
|
||||
networkId: actor.network_id,
|
||||
aliasFor: actor.alias_for,
|
||||
dateOfBirth: actor.date_of_birth,
|
||||
birthCountry: actor.birth_country_alpha2,
|
||||
})),
|
||||
tags: (release.tags || []).map(tag => ({
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
slug: tag.slug,
|
||||
})),
|
||||
...(withMedia && {
|
||||
poster: release.poster ? {
|
||||
@@ -67,7 +70,8 @@ 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,
|
||||
COALESCE(json_agg(DISTINCT actors) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors
|
||||
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('type', type)
|
||||
.leftJoin('sites', 'sites.id', 'releases.site_id')
|
||||
@@ -75,6 +79,8 @@ function withRelations(queryBuilder, withMedia = false, type = 'scene') {
|
||||
.leftJoin('networks as site_networks', 'site_networks.id', 'sites.network_id')
|
||||
.leftJoin('releases_actors', 'releases_actors.release_id', 'releases.id')
|
||||
.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')
|
||||
.groupBy(knex.raw(`
|
||||
releases.id, releases.entry_id, releases.shoot_id, releases.title, releases.url, releases.date, releases.description, releases.duration, releases.created_at,
|
||||
sites.id, networks.id, site_networks.id
|
||||
|
||||
Reference in New Issue
Block a user