refactor: replace ignored numeric literals with constants

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent a970eaaf7a
commit b78c215ff1
60 changed files with 510 additions and 283 deletions
@@ -13,6 +13,11 @@ import type { TbankInstrument } from './tbank.client';
import { PrismaService } from '../../prisma/prisma.service';
import { tbankSourceTtlMs } from './tbank-source.policy';
const FIRST_BATCH_OFFSET = 0;
const UNCHANGED_REVISION_INCREMENT = 0;
const REVISION_INCREMENT = 1;
const MISSING_DATA_REVISION = 0;
export type MetadataIdentity = {
figi?: null | string;
instrumentUid?: null | string;
@@ -59,7 +64,7 @@ export class InstrumentMetadataRepository {
),
];
for (
let offset = 0;
let offset = FIRST_BATCH_OFFSET;
offset < values.length;
offset += metadataReadBatchSize
) {
@@ -81,7 +86,7 @@ export class InstrumentMetadataRepository {
];
const instruments: MetadataRow[] = [];
for (
let offset = 0;
let offset = FIRST_BATCH_OFFSET;
offset < uids.length;
offset += metadataReadBatchSize
) {
@@ -229,8 +234,8 @@ export class InstrumentMetadataRepository {
...data,
dataRevision: {
increment: isDeepStrictEqual(previous?.metadata, payload) ?
0 :
1,
UNCHANGED_REVISION_INCREMENT :
REVISION_INCREMENT,
},
},
});
@@ -252,8 +257,8 @@ export class InstrumentMetadataRepository {
fetchedAt: now,
dataRevision: {
increment: isDeepStrictEqual(previous?.matchedUids, matchedUids) ?
0 :
1,
UNCHANGED_REVISION_INCREMENT :
REVISION_INCREMENT,
},
},
});
@@ -323,7 +328,7 @@ function selectMetadata(
dataRevision: used
.map(
(row) =>
`${row.lookup?.dataRevision ?? 0}:${row.instrument?.dataRevision ?? 0}`,
`${row.lookup?.dataRevision ?? MISSING_DATA_REVISION}:${row.instrument?.dataRevision ?? MISSING_DATA_REVISION}`,
)
.join('/'),
};