From 7b696e39de9c61370ec70ac53f4e36df8da39f2a Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Tue, 20 Jul 2021 21:07:17 +0200 Subject: [PATCH] add sorting and symbol as a result --- apps/api/src/app/core/current-rate.service.ts | 6 +++++- apps/api/src/app/core/market-data.service.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/api/src/app/core/current-rate.service.ts b/apps/api/src/app/core/current-rate.service.ts index 14edd4bc3..c63326105 100644 --- a/apps/api/src/app/core/current-rate.service.ts +++ b/apps/api/src/app/core/current-rate.service.ts @@ -25,7 +25,8 @@ export class CurrentRateService { const dataProviderResult = await this.dataProviderService.get([symbol]); return { date: resetHours(date), - marketPrice: dataProviderResult?.[symbol]?.marketPrice ?? 0 + marketPrice: dataProviderResult?.[symbol]?.marketPrice ?? 0, + symbol: symbol }; } @@ -37,6 +38,7 @@ export class CurrentRateService { if (marketData) { return { date: marketData.date, + symbol: marketData.symbol, marketPrice: this.exchangeRateDataService.toCurrency( marketData.marketPrice, currency, @@ -65,6 +67,7 @@ export class CurrentRateService { return marketData.map((marketDataItem) => { return { date: marketDataItem.date, + symbol: marketDataItem.symbol, marketPrice: this.exchangeRateDataService.toCurrency( marketDataItem.marketPrice, currencies[marketDataItem.symbol], @@ -99,5 +102,6 @@ export interface GetValuesParams { export interface GetValueObject { date: Date; + symbol: string; marketPrice: number; } diff --git a/apps/api/src/app/core/market-data.service.ts b/apps/api/src/app/core/market-data.service.ts index 873611ec0..7809ccf19 100644 --- a/apps/api/src/app/core/market-data.service.ts +++ b/apps/api/src/app/core/market-data.service.ts @@ -33,6 +33,14 @@ export class MarketDataService { symbols: string[]; }): Promise { return await this.prisma.marketData.findMany({ + orderBy: [ + { + date: 'asc' + }, + { + symbol: 'asc' + } + ], where: { date: { gte: dateRangeStart,