Browse Source

Refactoring

pull/1769/head
Thomas 3 years ago
parent
commit
d44de35923
  1. 6
      apps/api/src/app/exchange-rate/exchange-rate.controller.ts
  2. 7
      apps/api/src/app/exchange-rate/exchange-rate.service.ts

6
apps/api/src/app/exchange-rate/exchange-rate.controller.ts

@ -25,13 +25,13 @@ export class ExchangeRateController {
): Promise<IDataProviderHistoricalResponse> {
const date = new Date(dateString);
const { marketPrice } = await this.exchangeRateService.getExchangeRate({
const exchangeRate = await this.exchangeRateService.getExchangeRate({
date,
symbol
});
if (marketPrice) {
return { marketPrice };
if (exchangeRate) {
return { marketPrice: exchangeRate };
}
throw new HttpException(

7
apps/api/src/app/exchange-rate/exchange-rate.service.ts

@ -1,5 +1,4 @@
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
import { IDataProviderHistoricalResponse } from '@ghostfolio/api/services/interfaces/interfaces';
import { Injectable } from '@nestjs/common';
@Injectable()
@ -14,16 +13,14 @@ export class ExchangeRateService {
}: {
date: Date;
symbol: string;
}): Promise<IDataProviderHistoricalResponse> {
}): Promise<number> {
const [currency1, currency2] = symbol.split('-');
const marketPrice = await this.exchangeRateDataService.toCurrencyAtDate(
return this.exchangeRateDataService.toCurrencyAtDate(
1,
currency1,
currency2,
date
);
return { marketPrice };
}
}

Loading…
Cancel
Save