Browse Source

refactor(api): fallback to DEFAULT_CURRENCY in AdminController.addProfileData

pull/8476/head
KenTandrian 2 days ago
parent
commit
5e6305cba9
  1. 4
      apps/api/src/app/admin/admin.controller.ts
  2. 8
      apps/api/src/app/admin/admin.service.ts

4
apps/api/src/app/admin/admin.controller.ts

@ -11,6 +11,7 @@ import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'
import { import {
DATA_GATHERING_QUEUE_PRIORITY_HIGH, DATA_GATHERING_QUEUE_PRIORITY_HIGH,
DATA_GATHERING_QUEUE_PRIORITY_MEDIUM, DATA_GATHERING_QUEUE_PRIORITY_MEDIUM,
DEFAULT_CURRENCY,
GATHER_ASSET_PROFILE_PROCESS_JOB_NAME, GATHER_ASSET_PROFILE_PROCESS_JOB_NAME,
GATHER_ASSET_PROFILE_PROCESS_JOB_OPTIONS GATHER_ASSET_PROFILE_PROCESS_JOB_OPTIONS
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
@ -274,7 +275,8 @@ export class AdminController {
return this.adminService.addAssetProfile({ return this.adminService.addAssetProfile({
dataSource, dataSource,
symbol, symbol,
currency: this.request.user.settings.settings.baseCurrency currency:
this.request.user.settings.settings.baseCurrency ?? DEFAULT_CURRENCY
}); });
} }

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

@ -71,7 +71,7 @@ export class AdminService {
currency, currency,
dataSource, dataSource,
symbol symbol
}: AssetProfileIdentifier & { currency?: string }): Promise< }: AssetProfileIdentifier & { currency: string }): Promise<
SymbolProfile | never SymbolProfile | never
> { > {
try { try {
@ -82,12 +82,6 @@ export class AdminService {
); );
} }
if (!currency) {
throw new BadRequestException(
`currency is required for the data source ("${dataSource}")`
);
}
return this.symbolProfileService.add({ return this.symbolProfileService.add({
currency, currency,
dataSource, dataSource,

Loading…
Cancel
Save