|
|
@ -33,7 +33,14 @@ import { InjectQueue } from '@nestjs/bull'; |
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
import { Prisma } from '@prisma/client'; |
|
|
import { Prisma } from '@prisma/client'; |
|
|
import { Job, JobOptions, Queue } from 'bull'; |
|
|
import { Job, JobOptions, Queue } from 'bull'; |
|
|
import { format, min, subDays, subMilliseconds, subYears } from 'date-fns'; |
|
|
import { |
|
|
|
|
|
format, |
|
|
|
|
|
isBefore, |
|
|
|
|
|
min, |
|
|
|
|
|
subDays, |
|
|
|
|
|
subMilliseconds, |
|
|
|
|
|
subYears |
|
|
|
|
|
} from 'date-fns'; |
|
|
import ms, { StringValue } from 'ms'; |
|
|
import ms, { StringValue } from 'ms'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
@ -342,6 +349,10 @@ export class DataGatheringService { |
|
|
]?.marketPrice; |
|
|
]?.marketPrice; |
|
|
|
|
|
|
|
|
if (marketPrice) { |
|
|
if (marketPrice) { |
|
|
|
|
|
const state = isBefore(startOfUtcDate, getStartOfUtcDate(new Date())) |
|
|
|
|
|
? 'CLOSE' |
|
|
|
|
|
: 'INTRADAY'; |
|
|
|
|
|
|
|
|
return await this.prismaService.marketData.upsert({ |
|
|
return await this.prismaService.marketData.upsert({ |
|
|
create: { |
|
|
create: { |
|
|
dataSource, |
|
|
dataSource, |
|
|
@ -350,7 +361,7 @@ export class DataGatheringService { |
|
|
date: startOfUtcDate, |
|
|
date: startOfUtcDate, |
|
|
isCarriedForward: false |
|
|
isCarriedForward: false |
|
|
}, |
|
|
}, |
|
|
update: { marketPrice, isCarriedForward: false }, |
|
|
update: { marketPrice, state, isCarriedForward: false }, |
|
|
where: { |
|
|
where: { |
|
|
dataSource_symbol_date: { |
|
|
dataSource_symbol_date: { |
|
|
dataSource, |
|
|
dataSource, |
|
|
|