Browse Source

deleteProfileData refactored

pull/4354/head
csehatt741 6 months ago
committed by Attila Cseh
parent
commit
82d7b9c29e
  1. 35
      apps/api/src/app/admin/admin.service.ts
  2. 4
      apps/api/src/services/symbol-profile/symbol-profile.service.ts

35
apps/api/src/app/admin/admin.service.ts

@ -109,8 +109,24 @@ export class AdminService {
symbol
}: AssetProfileIdentifier) {
await this.marketDataService.deleteMany({ dataSource, symbol });
await this.symbolProfileService.delete({ dataSource, symbol });
await this.deleteCustomCurrency(symbol);
const currency = getCurrencyFromSymbol(symbol);
const customCurrencies = (await this.propertyService.getByKey(
PROPERTY_CURRENCIES
)) as string[];
if (customCurrencies.includes(currency)) {
const updatedCustomCurrencies = customCurrencies.filter(
(aCurrency) => aCurrency !== currency
);
await this.putSetting(
PROPERTY_CURRENCIES,
JSON.stringify(updatedCustomCurrencies)
);
} else {
await this.symbolProfileService.delete({ dataSource, symbol });
}
}
public async get(): Promise<AdminData> {
@ -777,19 +793,4 @@ export class AdminService {
}
);
}
private async deleteCustomCurrency(symbol: string) {
const currency = getCurrencyFromSymbol(symbol);
const customCurrencies = (await this.propertyService.getByKey(
PROPERTY_CURRENCIES
)) as string[];
const updatedCustomCurrencies = customCurrencies.filter(
(aCurrency) => aCurrency !== currency
);
await this.putSetting(
PROPERTY_CURRENCIES,
JSON.stringify(updatedCustomCurrencies)
);
}
}

4
apps/api/src/services/symbol-profile/symbol-profile.service.ts

@ -24,8 +24,8 @@ export class SymbolProfileService {
}
public async delete({ dataSource, symbol }: AssetProfileIdentifier) {
return this.prismaService.symbolProfile.deleteMany({
where: { dataSource, symbol }
return this.prismaService.symbolProfile.delete({
where: { dataSource_symbol: { dataSource, symbol } }
});
}

Loading…
Cancel
Save