fix(portfolio): publish new complete forecast regardless of request window (WealthLedger/backend#55) (#156)
This commit was merged in pull request #156.
This commit is contained in:
@@ -65,6 +65,14 @@ export class UpcomingEventDto {
|
||||
declare projectedAmount: MoneyDto | null;
|
||||
}
|
||||
|
||||
export class UpcomingEventsWindowDto {
|
||||
@ApiProperty({ format: 'date' })
|
||||
declare from: string;
|
||||
|
||||
@ApiProperty({ format: 'date' })
|
||||
declare to: string;
|
||||
}
|
||||
|
||||
export class UpcomingEventsDto {
|
||||
@ApiProperty()
|
||||
declare accountId: string;
|
||||
@@ -72,6 +80,13 @@ export class UpcomingEventsDto {
|
||||
@ApiProperty({ format: 'date-time' })
|
||||
declare calculatedAt: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: UpcomingEventsWindowDto,
|
||||
description:
|
||||
'Inclusive UTC window the saved forecast was calculated for. Unchanged by the requested from/to filter.',
|
||||
})
|
||||
declare window: UpcomingEventsWindowDto;
|
||||
|
||||
@ApiProperty({ type: UpcomingEventDto, isArray: true })
|
||||
declare events: UpcomingEventDto[];
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ export class UpcomingEventsService {
|
||||
a.type.localeCompare(b.type) ||
|
||||
a.ticker.localeCompare(b.ticker),
|
||||
);
|
||||
const candidate: undefined | UpcomingEventsDto = ready
|
||||
const candidate: Omit<UpcomingEventsDto, 'window'> | undefined = ready
|
||||
? {
|
||||
accountId,
|
||||
calculatedAt: new Date().toISOString(),
|
||||
@@ -163,6 +163,7 @@ export class UpcomingEventsService {
|
||||
revision: connection.revision,
|
||||
membershipRevision: connection.membershipRevision,
|
||||
scopeKey: `events/${JSON.stringify([accountId, window.from, window.to])}`,
|
||||
replacesLatest: query.from === undefined && query.to === undefined,
|
||||
portfolio: portfolio.meta,
|
||||
lastAttempt: hourlyAttempt(
|
||||
hourly,
|
||||
|
||||
Reference in New Issue
Block a user