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
@@ -8,6 +8,7 @@ import { randomUUID } from 'node:crypto';
import type { InvestmentResourceMetaDto } from '../investment-resource.dto';
import { ISO_DATE_LENGTH, ISO_DATE_START } from '../../../common/time';
import {
InstrumentMetadataService,
TbankAccessService,
@@ -41,6 +42,11 @@ import {
TbankSyncRepository,
} from './tbank-sync.repository';
const FOREGROUND_CANDLE_PRIORITY = 0;
const EXCLUSIVE_END_OFFSET_MS = 1;
const PENDING_CHILD_COUNT = 0;
const COMPLETED_CHILD_COUNT = 1;
@Injectable()
export class TbankSyncService {
private readonly runId = randomUUID();
@@ -279,8 +285,8 @@ export class TbankSyncService {
'bond-events',
],
{
from: source.from.toISOString().slice(0, 10),
to: source.to.toISOString().slice(0, 10),
from: source.from.toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH),
to: source.to.toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH),
ticker:
positions.find((position) => position.instrumentUid === uid)
?.ticker ?? undefined,
@@ -312,7 +318,7 @@ export class TbankSyncService {
},
now,
true,
0,
FOREGROUND_CANDLE_PRIORITY,
),
]);
}
@@ -479,7 +485,7 @@ export class TbankSyncService {
await add(
this.ledger.read(userId, accountId, {
from,
to: new Date(Date.parse(end) - 1).toISOString(),
to: new Date(Date.parse(end) - EXCLUSIVE_END_OFFSET_MS).toISOString(),
...(instrumentUid ? { instrumentUid } : {}),
sync: 'observe',
}),
@@ -509,7 +515,7 @@ export class TbankSyncService {
state,
errorCode: observed.errorCode,
progress: {
completed: state === 'running' ? 0 : 1,
completed: state === 'running' ? PENDING_CHILD_COUNT : COMPLETED_CHILD_COUNT,
total: 1,
discovering: false,
},