feat: add hourly portfolio sync history
This commit is contained in:
@@ -71,7 +71,7 @@ describe('operation completeness and freshness', () => {
|
||||
const asOf = new Date('2026-09-25T12:00:00Z');
|
||||
const covered = { accountId: 'a', from, to: asOf, asOf, fetchedAt: asOf };
|
||||
|
||||
it.each([1, 299, 300])(
|
||||
it.each([1, 3599, 3600])(
|
||||
'preserves the observed complete end after %s seconds, separately from TTL',
|
||||
(seconds) => {
|
||||
const now = new Date(asOf.valueOf() + seconds * 1000);
|
||||
@@ -85,10 +85,10 @@ describe('operation completeness and freshness', () => {
|
||||
availability: 'complete',
|
||||
asOf,
|
||||
to: asOf,
|
||||
stale: seconds >= 300,
|
||||
stale: seconds >= 3600,
|
||||
});
|
||||
expect(plan.load).toEqual(
|
||||
seconds >= 300 ? [{ accountId: 'a', from, to: now }] : [],
|
||||
[],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -128,7 +128,7 @@ export type OperationCoverage = OperationInterval & {
|
||||
asOf: Date;
|
||||
fetchedAt: Date;
|
||||
};
|
||||
const operationsFreshForMs = 300_000;
|
||||
const operationsFreshForMs = 3_600_000;
|
||||
|
||||
export function planOperationRead(
|
||||
requested: OperationInterval[],
|
||||
@@ -188,8 +188,9 @@ export function planOperationRead(
|
||||
.filter((row) => row.from < row.to),
|
||||
fresh.map((row) => ({ ...row, instrumentUid: target.instrumentUid })),
|
||||
).length > EMPTY_INTERVAL_COUNT;
|
||||
// The mutable tail is owned by the hourly walk; reads only load what is
|
||||
// missing, never re-verify complete or fresh intervals.
|
||||
if (options.force) load.push(target);
|
||||
else if (stale) load.push({ ...target, from: monthStart, to: now });
|
||||
else load.push(...missing);
|
||||
// Completeness is bounded by the observed end, never by the new wall clock.
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user