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

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

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

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

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

Loading…
Cancel
Save