refactor: replace ignored numeric literals with constants
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Failing after 2m17s
Conventional commits / commits (pull_request) Successful in 31s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 1m56s

This commit is contained in:
2026-09-28 11:24:59 +03:00
parent 9b3558f96c
commit 9cc9fbdcff
60 changed files with 510 additions and 283 deletions
@@ -27,6 +27,11 @@ import { CandleRepository } from '../infrastructure/candle.repository';
import { CatalogEnrichmentService } from './catalog-enrichment.service';
import { timestamp } from './instrument-market';
const FIRST_BATCH_OFFSET = 0;
const BACKGROUND_SYNC_PRIORITY = 2;
const REPLACED_WINDOW_COUNT = 1;
const NEXT_WINDOW_OFFSET = 1;
type CandleInput = {
instrumentType: 'bond' | 'share';
period: 'all' | 'halfYear' | 'month' | 'year';
@@ -246,7 +251,7 @@ export class CandleService {
)
.map(([uid]) => uid);
for (
let offset = 0;
let offset = FIRST_BATCH_OFFSET;
offset < uids.length;
offset += prefetchReadBatchSize
) {
@@ -297,7 +302,7 @@ export class CandleService {
now,
).length
) {
await this.request(userId, revision, input, now, false, 2);
await this.request(userId, revision, input, now, false, BACKGROUND_SYNC_PRIORITY);
}
}
}
@@ -393,7 +398,7 @@ export class CandleService {
const gaps = candleGaps(window, latest.coverage, now)
.flatMap(candleWindows)
.reverse();
ranges.splice(index, 1, ...gaps);
ranges.splice(index, REPLACED_WINDOW_COUNT, ...gaps);
// eslint-disable-next-line security/detect-object-injection -- The index is the internal numeric window cursor.
window = ranges[index];
}
@@ -430,7 +435,7 @@ export class CandleService {
) {
return false;
}
pass.nextWindow = index + 1;
pass.nextWindow = index + NEXT_WINDOW_OFFSET;
if (pass.nextWindow < ranges.length) return null;
}
return true;
@@ -512,7 +517,7 @@ export class CandleService {
{ ...producer.input, period: 'all' },
producer.now,
false,
2,
BACKGROUND_SYNC_PRIORITY,
);
}
}