fix: call time stop when time is more than estimation
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
1692c8234a
commit
551bd12f5b
|
@ -17,8 +17,7 @@ export function phoneNumberOnly(phone: string): string {
|
||||||
export function timeIsBefore(
|
export function timeIsBefore(
|
||||||
currentTime: number,
|
currentTime: number,
|
||||||
time: number,
|
time: number,
|
||||||
diff = 15,
|
diffInMilliseconds: number,
|
||||||
): boolean {
|
): boolean {
|
||||||
const diffInMilliseconds = diff * 60 * 1000;
|
|
||||||
return time < currentTime + diffInMilliseconds;
|
return time < currentTime + diffInMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
} from 'src/core/strings/constants/base.constants';
|
} from 'src/core/strings/constants/base.constants';
|
||||||
import { QueueTimeFormula } from './usecases/formula/queue-time.formula';
|
import { QueueTimeFormula } from './usecases/formula/queue-time.formula';
|
||||||
import * as moment from 'moment';
|
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 { WhatsappService } from 'src/services/whatsapp/whatsapp.service';
|
||||||
import { WhatsappQueue } from 'src/services/whatsapp/entity/whatsapp-queue.entity';
|
import { WhatsappQueue } from 'src/services/whatsapp/entity/whatsapp-queue.entity';
|
||||||
|
|
||||||
|
@ -63,11 +63,12 @@ export class QueueAdminOrchestrator {
|
||||||
for (const queueId in queueTimes) {
|
for (const queueId in queueTimes) {
|
||||||
const callTime = queueTimes[queueId];
|
const callTime = queueTimes[queueId];
|
||||||
|
|
||||||
|
const queueTicket = await this.service.queueTicket(queueId);
|
||||||
if (
|
if (
|
||||||
queueItem.requiring_notification ||
|
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 = {
|
const payload: WhatsappQueue = {
|
||||||
id: queueId,
|
id: queueId,
|
||||||
phone: queueTicket.item.ticket.phone,
|
phone: queueTicket.item.ticket.phone,
|
||||||
|
|
Loading…
Reference in New Issue