Redirecting aliased actors and tags.
This commit is contained in:
@@ -254,10 +254,12 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
knex.raw('row_to_json(sfw_media) as sfw_avatar'),
|
||||
// knex.raw('json_agg(aliases) filter (where aliases.id is not null) as aliases'),
|
||||
knex.raw('json_agg(row_to_json(aliases)::jsonb || jsonb_build_object(\'entity\', row_to_json(alias_entities))) filter (where aliases.id is not null) as aliases'),
|
||||
knex.raw('row_to_json(aliased) as alias'),
|
||||
knex.raw('row_to_json(media_biometrics) as biometrics'),
|
||||
)
|
||||
.leftJoin('actors_meta', 'actors_meta.actor_id', 'actors.id')
|
||||
.leftJoin('actors as aliases', 'aliases.alias_for', 'actors.id')
|
||||
.leftJoin('actors as aliased', 'aliased.id', 'actors.alias_for')
|
||||
.leftJoin('entities as alias_entities', 'alias_entities.id', 'aliases.entity_id')
|
||||
.leftJoin('countries as birth_countries', 'birth_countries.alpha2', 'actors.birth_country_alpha2')
|
||||
.leftJoin('countries as residence_countries', 'residence_countries.alpha2', 'actors.residence_country_alpha2')
|
||||
@@ -265,7 +267,7 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
||||
.leftJoin('media_biometrics', 'media_biometrics.media_id', 'actors.avatar_media_id')
|
||||
.leftJoin('entities', 'entities.id', 'actors.entity_id')
|
||||
.groupBy('actors.id', 'avatars.id', 'sfw_media.id', 'media_biometrics.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2');
|
||||
.groupBy('actors.id', 'aliased.id', 'avatars.id', 'sfw_media.id', 'media_biometrics.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2');
|
||||
}
|
||||
}),
|
||||
knex('actors_profiles')
|
||||
|
||||
@@ -422,7 +422,7 @@ export async function fetchMovies(filters, rawOptions, reqUser, context) {
|
||||
|
||||
const [aggActors, aggTags, aggChannels] = await Promise.all([
|
||||
options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { shadllow: true, order: ['slug', 'asc'], append: actorCounts }, reqUser) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(tags.name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateChannels ? fetchEntitiesById(result.aggregations.channelIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }, reqUser, context) : [],
|
||||
]);
|
||||
|
||||
|
||||
@@ -689,8 +689,8 @@ export async function fetchScenes(filters, rawOptions, reqUser, context) {
|
||||
|
||||
const [aggActors, aggTags, aggActorTags, aggChannels] = await Promise.all([
|
||||
options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { shallow: true, order: ['slug', 'asc'], append: actorCounts }, reqUser) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.actorTagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(tags.name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateTags ? fetchTagsById(result.aggregations.actorTagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(tags.name)'), 'asc'], append: tagCounts }, reqUser, context) : [],
|
||||
options.aggregateChannels ? fetchEntitiesById(entityIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }, reqUser, context) : [],
|
||||
]);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ function curateTag(tag, context = {}) {
|
||||
priority: tag.priority,
|
||||
poster: tag.poster && curateMedia(tag.poster),
|
||||
photos: tag.photos?.map((photo) => curateMedia(photo)) || [],
|
||||
aliasFor: tag.alias_slug,
|
||||
alerts: {
|
||||
only: context?.alerts?.filter((alert) => alert.is_only).flatMap((alert) => alert.alert_ids) || [],
|
||||
multi: context?.alerts?.filter((alert) => !alert.is_only).flatMap((alert) => alert.alert_ids) || [],
|
||||
@@ -76,6 +77,8 @@ export async function fetchTags(options = {}, context = {}) {
|
||||
export async function fetchTagsById(tagIds, options = {}, reqUser, context = {}) {
|
||||
const [tags, posters, photos, alerts] = await Promise.all([
|
||||
knex('tags')
|
||||
.select('tags.*', 'aliases.slug as alias_slug')
|
||||
.leftJoin('tags as aliases', 'aliases.id', 'tags.alias_for')
|
||||
.whereIn('tags.id', tagIds.filter((tagId) => typeof tagId === 'number'))
|
||||
.orWhereIn('tags.slug', tagIds.filter((tagId) => typeof tagId === 'string'))
|
||||
.modify((builder) => {
|
||||
|
||||
Reference in New Issue
Block a user