mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
fix(cdr-enrichment): 35s sleep between date fetches — Ozonetel caps at 2/min
The first boot hit 429 because two dates (today + yesterday) were fetched back-to-back, and the dispose flow's fetchCdrByUCID shares the same 2-req/min budget. 35s between dates keeps us clear of the cap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,8 +53,12 @@ export class CdrEnrichmentService implements OnModuleInit, OnModuleDestroy {
|
||||
let skipped = 0;
|
||||
|
||||
// Walk the IST-date window. For each date, pull CDR + patch Calls.
|
||||
// Sleep 35s between dates — Ozonetel caps CDR endpoints at 2 req/min
|
||||
// and the dispose flow shares that budget (fetchCdrByUCID per outbound).
|
||||
const dates = this.recentDatesIst(ENRICHMENT_DATE_WINDOW_DAYS);
|
||||
for (const date of dates) {
|
||||
for (let i = 0; i < dates.length; i++) {
|
||||
const date = dates[i];
|
||||
if (i > 0) await new Promise((r) => setTimeout(r, 35_000));
|
||||
const cdrRows = await this.ozonetel.fetchCDR({ date }).catch(() => []);
|
||||
if (cdrRows.length === 0) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user