|
@ -120,14 +120,16 @@ export class ImportService { |
|
|
const existingAccounts = await this.accountService.accounts({ |
|
|
const existingAccounts = await this.accountService.accounts({ |
|
|
where: { |
|
|
where: { |
|
|
id: { |
|
|
id: { |
|
|
in: accountsDto.map((account) => account.id) |
|
|
in: accountsDto.map(({ id }) => { |
|
|
|
|
|
return id; |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create new accounts during dryRun so that new account IDs don't get invalidated
|
|
|
// Create new accounts during dryRun so that new account IDs don't get invalidated
|
|
|
if (isDryRun && accountsDto?.length) { |
|
|
if (isDryRun && accountsDto?.length) { |
|
|
for (let account of accountsDto) { |
|
|
for (const account of accountsDto) { |
|
|
// Check if there is any existing account with the same ID
|
|
|
// Check if there is any existing account with the same ID
|
|
|
const accountWithSameId = existingAccounts.find( |
|
|
const accountWithSameId = existingAccounts.find( |
|
|
(existingAccount) => existingAccount.id === account.id |
|
|
(existingAccount) => existingAccount.id === account.id |
|
@ -145,19 +147,19 @@ export class ImportService { |
|
|
delete account.id; |
|
|
delete account.id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const newAccountObj = { |
|
|
const newAccountObject = { |
|
|
...account, |
|
|
...account, |
|
|
User: { connect: { id: userId } } |
|
|
User: { connect: { id: userId } } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (platformId) { |
|
|
if (platformId) { |
|
|
Object.assign(newAccountObj, { |
|
|
Object.assign(newAccountObject, { |
|
|
Platform: { connect: { id: platformId } } |
|
|
Platform: { connect: { id: platformId } } |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const newAccount = await this.accountService.createAccount( |
|
|
const newAccount = await this.accountService.createAccount( |
|
|
newAccountObj, |
|
|
newAccountObject, |
|
|
userId |
|
|
userId |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|