Browse Source

Remove getAccountById method and its usage

pull/1635/head
yksolanki9 3 years ago
committed by Thomas
parent
commit
dcc857a2ba
  1. 7
      apps/api/src/app/account/account.service.ts
  2. 12
      apps/api/src/app/import/import.service.ts

7
apps/api/src/app/account/account.service.ts

@ -80,13 +80,6 @@ export class AccountService {
}); });
} }
public async getAccountById(accountId: string) {
const accounts = await this.accounts({
where: { id: accountId }
});
return accounts.length ? accounts[0] : null;
}
public async getAccounts(aUserId: string) { public async getAccounts(aUserId: string) {
const accounts = await this.accounts({ const accounts = await this.accounts({
include: { Order: true, Platform: true }, include: { Order: true, Platform: true },

12
apps/api/src/app/import/import.service.ts

@ -117,12 +117,20 @@ export class ImportService {
}): Promise<Activity[]> { }): Promise<Activity[]> {
const accountIdMapping: { [oldAccountId: string]: string } = {}; const accountIdMapping: { [oldAccountId: string]: string } = {};
const existingAccounts = await this.accountService.accounts({
where: {
id: {
in: accountsDto.map((account) => account.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 (let 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 = await this.accountService.getAccountById( const accountWithSameId = existingAccounts.find(
account.id (existingAccount) => existingAccount.id === account.id
); );
//If there is no account or if the account belongs to a different user then create a new account //If there is no account or if the account belongs to a different user then create a new account

Loading…
Cancel
Save