|
|
@ -371,7 +371,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
|
|
|
|
|
|
public async getHistorical( |
|
|
public async getHistorical( |
|
|
aItems: AssetProfileIdentifier[], |
|
|
aItems: AssetProfileIdentifier[], |
|
|
aGranularity: Granularity = 'month', |
|
|
|
|
|
from: Date, |
|
|
from: Date, |
|
|
to: Date |
|
|
to: Date |
|
|
): Promise<{ |
|
|
): Promise<{ |
|
|
@ -389,11 +388,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
return response; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const granularityQuery = |
|
|
|
|
|
aGranularity === 'month' |
|
|
|
|
|
? Prisma.sql`AND (date_part('day', date) = 1 OR date >= TIMESTAMP 'yesterday')` |
|
|
|
|
|
: Prisma.empty; |
|
|
|
|
|
|
|
|
|
|
|
const rangeQuery = |
|
|
const rangeQuery = |
|
|
from && to |
|
|
from && to |
|
|
? Prisma.sql`AND date >= ${format(from, DATE_FORMAT, { |
|
|
? Prisma.sql`AND date >= ${format(from, DATE_FORMAT, { |
|
|
@ -415,7 +409,6 @@ export class DataProviderService implements OnModuleInit { |
|
|
SELECT "dataSource", "date", "marketPrice", "symbol" |
|
|
SELECT "dataSource", "date", "marketPrice", "symbol" |
|
|
FROM "MarketData" |
|
|
FROM "MarketData" |
|
|
WHERE ("dataSource", "symbol") IN (${Prisma.join(assetProfileIdentifiers)}) |
|
|
WHERE ("dataSource", "symbol") IN (${Prisma.join(assetProfileIdentifiers)}) |
|
|
${granularityQuery} |
|
|
|
|
|
${rangeQuery} |
|
|
${rangeQuery} |
|
|
ORDER BY date;`;
|
|
|
ORDER BY date;`;
|
|
|
|
|
|
|
|
|
|