T-69: Bug sweep (3 bugs: T-64, T-67, T-71)

This commit is contained in:
Studio 2026-11-27 19:36:35 -05:00
parent cb59177c3e
commit cd43681351
2 changed files with 178 additions and 9 deletions

View file

@ -447,11 +447,16 @@ export function linkDelistingChains(
const reportedDuplicateKeyIds = new Set<string>();
const droppedOtcKeysByGroup = new Map<string, Map<string, ListingNaturalKey>>();
const recordDroppedOtcIfApplicable = (key: ListingNaturalKey, keyId: string): void => {
const recordDroppedOtcIfApplicable = (
key: ListingNaturalKey,
keyId: string,
listedFromDay: number | null
): void => {
if (
!normalizedOtcMics.has(key.mic) ||
key.primaryIsin.length === 0 ||
key.currency.length === 0
key.currency.length === 0 ||
(listedFromDay !== null && listedFromDay > asOfDay)
) {
return;
}
@ -481,7 +486,7 @@ export function linkDelistingChains(
const occurrences = keyCounts.get(keyId) ?? 0;
if (occurrences > 1) {
skippedDuplicateKeys += 1;
recordDroppedOtcIfApplicable(key, keyId);
recordDroppedOtcIfApplicable(key, keyId, parseExactIsoDateToUtcDay(row.listedFrom));
if (!reportedDuplicateKeyIds.has(keyId)) {
reportedDuplicateKeyIds.add(keyId);
conflicts.push({
@ -533,7 +538,7 @@ export function linkDelistingChains(
if (dateErrorReason !== null) {
skippedInvalidDates += 1;
recordDroppedOtcIfApplicable(key, keyId);
recordDroppedOtcIfApplicable(key, keyId, listedFromDay);
conflicts.push({
conflictKind: 'invalid_listing_dates',
detail: {
@ -624,10 +629,8 @@ export function linkDelistingChains(
const allKeys = [...sortedPrimaryKeys, ...sortedBlockingOtcKeys].sort(
compareListingNaturalKey
);
const singleMissingOnly =
group.missingFromOtcs.length === 1 && droppedOtcCount === 0
? group.missingFromOtcs[0]
: undefined;
const singleMissingOtc =
group.missingFromOtcs.length === 1 ? group.missingFromOtcs[0] : undefined;
let reason: string;
if (droppedOtcCount === 0) {
reason =
@ -651,7 +654,7 @@ export function linkDelistingChains(
toListingKeys: sortedBlockingOtcKeys.map(cloneListingKey),
candidateListingKeys: allKeys.map(cloneListingKey),
listedFrom: null,
listedTo: singleMissingOnly !== undefined ? singleMissingOnly.listedTo : null,
listedTo: singleMissingOtc !== undefined ? singleMissingOtc.listedTo : null,
reason,
},
});