Skip to content

Commit

Permalink
Compose exchange rates dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
dtslvr committed Sep 22, 2021
1 parent 7f978ff commit 794349c
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions apps/api/src/app/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration.ser
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
import { baseCurrency } from '@ghostfolio/common/config';
import { AdminData } from '@ghostfolio/common/interfaces';
import { Injectable } from '@nestjs/common';
import { differenceInDays } from 'date-fns';
Expand All @@ -19,33 +20,22 @@ export class AdminService {

public async get(): Promise<AdminData> {
return {
exchangeRates: [
{
label1: 'EUR',
label2: 'CHF',
value: await this.exchangeRateDataService.toCurrency(1, 'EUR', 'CHF')
},
{
label1: 'GBP',
label2: 'CHF',
value: await this.exchangeRateDataService.toCurrency(1, 'GBP', 'CHF')
},
{
label1: 'USD',
label2: 'CHF',
value: await this.exchangeRateDataService.toCurrency(1, 'USD', 'CHF')
},
{
label1: 'USD',
label2: 'EUR',
value: await this.exchangeRateDataService.toCurrency(1, 'USD', 'EUR')
},
{
label1: 'USD',
label2: 'GBP',
value: await this.exchangeRateDataService.toCurrency(1, 'USD', 'GBP')
}
],
exchangeRates: this.exchangeRateDataService
.getCurrencies()
.filter((currency) => {
return currency !== baseCurrency;
})
.map((currency) => {
return {
label1: baseCurrency,
label2: currency,
value: this.exchangeRateDataService.toCurrency(
1,
baseCurrency,
currency
)
};
}),
lastDataGathering: await this.getLastDataGathering(),
transactionCount: await this.prismaService.order.count(),
userCount: await this.prismaService.user.count(),
Expand Down

0 comments on commit 794349c

Please sign in to comment.