Browse Source

review changes

- adjust order of param
pull/2436/head
Kevin Lien 2 years ago
committed by Thomas
parent
commit
485b0246fd
  1. 8
      apps/api/src/app/benchmark/benchmark.service.ts
  2. 37
      apps/api/src/services/market-data/market-data.service.ts
  3. 2
      libs/common/src/lib/interfaces/benchmark.interface.ts

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

@ -64,7 +64,7 @@ export class BenchmarkService {
const benchmarkAssetProfiles = await this.getBenchmarkAssetProfiles(); const benchmarkAssetProfiles = await this.getBenchmarkAssetProfiles();
const promises: Promise<{ marketPrice: number; date: Date }>[] = []; const promises: Promise<{ date: Date; marketPrice: number }>[] = [];
const quotes = await this.dataProviderService.getQuotes({ const quotes = await this.dataProviderService.getQuotes({
items: benchmarkAssetProfiles.map(({ dataSource, symbol }) => { items: benchmarkAssetProfiles.map(({ dataSource, symbol }) => {
@ -85,7 +85,7 @@ export class BenchmarkService {
let performancePercentFromAllTimeHigh = 0; let performancePercentFromAllTimeHigh = 0;
if (allTimeHigh && allTimeHigh.marketPrice && marketPrice) { if (allTimeHigh?.marketPrice && marketPrice) {
performancePercentFromAllTimeHigh = this.calculateChangeInPercentage( performancePercentFromAllTimeHigh = this.calculateChangeInPercentage(
allTimeHigh.marketPrice, allTimeHigh.marketPrice,
marketPrice marketPrice
@ -100,8 +100,8 @@ export class BenchmarkService {
name: benchmarkAssetProfiles[index].name, name: benchmarkAssetProfiles[index].name,
performances: { performances: {
allTimeHigh: { allTimeHigh: {
performancePercent: performancePercentFromAllTimeHigh, date: allTimeHigh.date,
date: allTimeHigh.date performancePercent: performancePercentFromAllTimeHigh
} }
} }
}; };

37
apps/api/src/services/market-data/market-data.service.ts

@ -39,27 +39,22 @@ export class MarketDataService {
}); });
} }
public async getMax({ public async getMax({ dataSource, symbol }: UniqueAsset) {
dataSource, return this.prismaService.marketData.findFirst({
symbol select: {
}: UniqueAsset): Promise<{ marketPrice: number; date: Date }> { date: true,
const highestMarketPriceDataRow = marketPrice: true
await this.prismaService.marketData.findFirst({ },
select: { orderBy: [
marketPrice: true, {
date: true marketPrice: 'desc'
}, }
where: { ],
dataSource, where: {
symbol dataSource,
}, symbol
orderBy: [ }
{ });
marketPrice: 'desc'
}
]
});
return highestMarketPriceDataRow;
} }
public async getRange({ public async getRange({

2
libs/common/src/lib/interfaces/benchmark.interface.ts

@ -5,8 +5,8 @@ export interface Benchmark {
name: EnhancedSymbolProfile['name']; name: EnhancedSymbolProfile['name'];
performances: { performances: {
allTimeHigh: { allTimeHigh: {
performancePercent: number;
date: Date; date: Date;
performancePercent: number;
}; };
}; };
} }

Loading…
Cancel
Save