fix(portfolio): publish new complete forecast regardless of request window (WealthLedger/backend#55) (#156)
Backend verify / commits (push) Skipped
Backend verify / security (push) Successful in 1m11s
Backend verify / verify (push) Failing after 7m6s

This commit was merged in pull request #156.
This commit is contained in:
2026-11-02 22:42:46 +03:00
parent 554410a271
commit 169bee1da5
5 changed files with 182 additions and 29 deletions
@@ -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,