Compare commits
2
Commits
244dc4fff6
...
497c6150f7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
497c6150f7 | ||
|
|
514f51f111 |
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "traxxx-web",
|
||||
"version": "0.50.21",
|
||||
"version": "0.50.22",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.50.21",
|
||||
"version": "0.50.22",
|
||||
"dependencies": {
|
||||
"@brillout/json-serializer": "^0.5.8",
|
||||
"@dicebear/collection": "^7.0.5",
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@
|
||||
"overrides": {
|
||||
"vite": "$vite"
|
||||
},
|
||||
"version": "0.50.21",
|
||||
"version": "0.50.22",
|
||||
"imports": {
|
||||
"#/*": "./*.js"
|
||||
}
|
||||
|
||||
+11
-1
@@ -616,9 +616,11 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
let mergedActorStashes = [];
|
||||
|
||||
try {
|
||||
const [existingProfiles] = await Promise.all([
|
||||
const [existingProfiles, sourceProfiles] = await Promise.all([
|
||||
trx('actors_profiles')
|
||||
.where('actor_id', targetActorId),
|
||||
trx('actors_profiles')
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
trx('actors')
|
||||
.update('alias_for', targetActorId)
|
||||
.whereIn('id', sourceActorIds)
|
||||
@@ -629,11 +631,19 @@ export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
]);
|
||||
|
||||
// multiple source actors may provide profiles for the same entity, but we can only assign one to the target actor; prefer the newest
|
||||
const newestSourceProfileMap = Object.fromEntries(sourceProfiles
|
||||
.toSorted((profileA, profileB) => profileA.updated_at - profileB.updated_at)
|
||||
.map((profile) => [profile.entity_id, profile.id]));
|
||||
|
||||
const duplicateSourceProfiles = sourceProfiles.filter((profile) => newestSourceProfileMap[profile.entity_id] && newestSourceProfileMap[profile.entity_id] !== profile.id);
|
||||
|
||||
// assign source actor profiles to target actor, unless a profile for that entity is already present
|
||||
mergedProfiles = await trx('actors_profiles')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.whereNotIn('entity_id', existingProfiles.map((profile) => profile.entity_id))
|
||||
.whereNotIn('id', duplicateSourceProfiles.map((profile) => profile.id))
|
||||
.returning('id');
|
||||
|
||||
// find releases that have more than one source actor assigned
|
||||
|
||||
Reference in New Issue
Block a user