refactor: isolate operation ranges and intents
This commit is contained in:
@@ -106,6 +106,24 @@ export function uncoveredOperationIntervals(
|
||||
});
|
||||
}
|
||||
|
||||
export function confirmedOperationRanges(
|
||||
targets: OperationInterval[],
|
||||
coverage: OperationInterval[],
|
||||
): Omit<OperationInterval, 'instrumentUid'>[] {
|
||||
return targets.flatMap((target) => coverage
|
||||
.filter((row) =>
|
||||
row.accountId === target.accountId &&
|
||||
(!row.instrumentUid || row.instrumentUid === target.instrumentUid) &&
|
||||
row.from < target.to && target.from < row.to,
|
||||
)
|
||||
.map((row) => ({
|
||||
accountId: target.accountId,
|
||||
from: new Date(Math.max(row.from.valueOf(), target.from.valueOf())),
|
||||
to: new Date(Math.min(row.to.valueOf(), target.to.valueOf())),
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
export type OperationCoverage = OperationInterval & {
|
||||
asOf: Date;
|
||||
fetchedAt: Date;
|
||||
|
||||
Reference in New Issue
Block a user