add sorting and symbol as a result

This commit is contained in:
Valentin Zickner 2021-07-20 21:07:17 +02:00 committed by Thomas
parent c88ad2c225
commit 7b696e39de
2 changed files with 13 additions and 1 deletions

View File

@ -25,7 +25,8 @@ export class CurrentRateService {
const dataProviderResult = await this.dataProviderService.get([symbol]); const dataProviderResult = await this.dataProviderService.get([symbol]);
return { return {
date: resetHours(date), date: resetHours(date),
marketPrice: dataProviderResult?.[symbol]?.marketPrice ?? 0 marketPrice: dataProviderResult?.[symbol]?.marketPrice ?? 0,
symbol: symbol
}; };
} }
@ -37,6 +38,7 @@ export class CurrentRateService {
if (marketData) { if (marketData) {
return { return {
date: marketData.date, date: marketData.date,
symbol: marketData.symbol,
marketPrice: this.exchangeRateDataService.toCurrency( marketPrice: this.exchangeRateDataService.toCurrency(
marketData.marketPrice, marketData.marketPrice,
currency, currency,
@ -65,6 +67,7 @@ export class CurrentRateService {
return marketData.map((marketDataItem) => { return marketData.map((marketDataItem) => {
return { return {
date: marketDataItem.date, date: marketDataItem.date,
symbol: marketDataItem.symbol,
marketPrice: this.exchangeRateDataService.toCurrency( marketPrice: this.exchangeRateDataService.toCurrency(
marketDataItem.marketPrice, marketDataItem.marketPrice,
currencies[marketDataItem.symbol], currencies[marketDataItem.symbol],
@ -99,5 +102,6 @@ export interface GetValuesParams {
export interface GetValueObject { export interface GetValueObject {
date: Date; date: Date;
symbol: string;
marketPrice: number; marketPrice: number;
} }

View File

@ -33,6 +33,14 @@ export class MarketDataService {
symbols: string[]; symbols: string[];
}): Promise<MarketData[]> { }): Promise<MarketData[]> {
return await this.prisma.marketData.findMany({ return await this.prisma.marketData.findMany({
orderBy: [
{
date: 'asc'
},
{
symbol: 'asc'
}
],
where: { where: {
date: { date: {
gte: dateRangeStart, gte: dateRangeStart,