From 551bd12f5be6baaba1a0076704b9b676024fe626 Mon Sep 17 00:00:00 2001 From: shancheas Date: Wed, 25 Dec 2024 04:57:28 +0700 Subject: [PATCH] fix: call time stop when time is more than estimation --- src/modules/queue/domain/helpers/time.helper.ts | 3 +-- src/modules/queue/domain/queue-admin.orchestrator.ts | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/queue/domain/helpers/time.helper.ts b/src/modules/queue/domain/helpers/time.helper.ts index 8a5e05f..eaa09d9 100644 --- a/src/modules/queue/domain/helpers/time.helper.ts +++ b/src/modules/queue/domain/helpers/time.helper.ts @@ -17,8 +17,7 @@ export function phoneNumberOnly(phone: string): string { export function timeIsBefore( currentTime: number, time: number, - diff = 15, + diffInMilliseconds: number, ): boolean { - const diffInMilliseconds = diff * 60 * 1000; return time < currentTime + diffInMilliseconds; } diff --git a/src/modules/queue/domain/queue-admin.orchestrator.ts b/src/modules/queue/domain/queue-admin.orchestrator.ts index 9bfc106..74feb66 100644 --- a/src/modules/queue/domain/queue-admin.orchestrator.ts +++ b/src/modules/queue/domain/queue-admin.orchestrator.ts @@ -14,7 +14,7 @@ import { } from 'src/core/strings/constants/base.constants'; import { QueueTimeFormula } from './usecases/formula/queue-time.formula'; import * as moment from 'moment'; -import { timeIsBefore, toTime } from './helpers/time.helper'; +import { timeIsBefore } from './helpers/time.helper'; import { WhatsappService } from 'src/services/whatsapp/whatsapp.service'; import { WhatsappQueue } from 'src/services/whatsapp/entity/whatsapp-queue.entity'; @@ -63,11 +63,12 @@ export class QueueAdminOrchestrator { for (const queueId in queueTimes) { const callTime = queueTimes[queueId]; + const queueTicket = await this.service.queueTicket(queueId); if ( queueItem.requiring_notification || - timeIsBefore(currentTime, callTime, queueItem.call_preparation) + (timeIsBefore(currentTime, callTime, call_preparation) && + queueTicket.time > currentTime) ) { - const queueTicket = await this.service.queueTicket(queueId); const payload: WhatsappQueue = { id: queueId, phone: queueTicket.item.ticket.phone,