Browse Source
Task/remove unused granularity from historical market data query (#8111)
Remove unused granularity from historical market data query
pull/8116/head
Thomas Kaul
4 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
0 additions and
9 deletions
-
apps/api/src/app/portfolio/portfolio.service.ts
-
apps/api/src/services/data-provider/data-provider.service.ts
-
apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts
|
|
|
@ -1052,7 +1052,6 @@ export class PortfolioService { |
|
|
|
|
|
|
|
const historicalData = await this.dataProviderService.getHistorical( |
|
|
|
[{ dataSource, symbol }], |
|
|
|
'day', |
|
|
|
parseISO(dateOfFirstActivity, { in: utc }), |
|
|
|
new Date() |
|
|
|
); |
|
|
|
|
|
|
|
@ -371,7 +371,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
|
|
|
|
|
public async getHistorical( |
|
|
|
aItems: AssetProfileIdentifier[], |
|
|
|
aGranularity: Granularity = 'month', |
|
|
|
from: Date, |
|
|
|
to: Date |
|
|
|
): Promise<{ |
|
|
|
@ -389,11 +388,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
const granularityQuery = |
|
|
|
aGranularity === 'month' |
|
|
|
? Prisma.sql`AND (date_part('day', date) = 1 OR date >= TIMESTAMP 'yesterday')` |
|
|
|
: Prisma.empty; |
|
|
|
|
|
|
|
const rangeQuery = |
|
|
|
from && to |
|
|
|
? Prisma.sql`AND date >= ${format(from, DATE_FORMAT, { |
|
|
|
@ -415,7 +409,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
|
SELECT "dataSource", "date", "marketPrice", "symbol" |
|
|
|
FROM "MarketData" |
|
|
|
WHERE ("dataSource", "symbol") IN (${Prisma.join(assetProfileIdentifiers)}) |
|
|
|
${granularityQuery} |
|
|
|
${rangeQuery} |
|
|
|
ORDER BY date;`;
|
|
|
|
|
|
|
|
|
|
|
|
@ -175,7 +175,6 @@ export class ExchangeRateDataService { |
|
|
|
|
|
|
|
const historicalData = await this.dataProviderService.getHistorical( |
|
|
|
this.currencyPairs, |
|
|
|
'day', |
|
|
|
startOfUtcDateOfYesterday, |
|
|
|
startOfUtcDateOfYesterday |
|
|
|
); |
|
|
|
|