fix: use HH:MM:SS format for Ozonetel abandonCalls time params

Ozonetel API expects time-of-day format (HH:MM:SS), not full datetime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 12:50:57 +05:30
parent 30a4cda178
commit 0b98d490f0

View File

@@ -37,13 +37,14 @@ export class MissedQueueService implements OnModuleInit {
let created = 0; let created = 0;
let updated = 0; let updated = 0;
// Ozonetel fromTime/toTime use HH:MM:SS format (time of day, filters within current day)
const now = new Date(); const now = new Date();
const fiveMinAgo = new Date(now.getTime() - 5 * 60 * 1000); const fiveMinAgo = new Date(now.getTime() - 5 * 60 * 1000);
const format = (d: Date) => d.toISOString().replace('T', ' ').slice(0, 19); const toHHMMSS = (d: Date) => d.toTimeString().slice(0, 8);
let abandonCalls: any[]; let abandonCalls: any[];
try { try {
abandonCalls = await this.ozonetel.getAbandonCalls({ fromTime: format(fiveMinAgo), toTime: format(now) }); abandonCalls = await this.ozonetel.getAbandonCalls({ fromTime: toHHMMSS(fiveMinAgo), toTime: toHHMMSS(now) });
} catch (err) { } catch (err) {
this.logger.warn(`Failed to fetch abandon calls: ${err}`); this.logger.warn(`Failed to fetch abandon calls: ${err}`);
return { created: 0, updated: 0 }; return { created: 0, updated: 0 };