fix: call time stop when time is more than estimation
continuous-integration/drone/push Build is passing Details

pull/121/head
shancheas 2024-12-25 04:57:28 +07:00
parent 1692c8234a
commit 551bd12f5b
2 changed files with 5 additions and 5 deletions

View File

@ -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;
}

View File

@ -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,