fix: total QR header
parent
3b7d7ea80b
commit
1148a72481
|
@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Between, In, IsNull, Not, Repository } from 'typeorm';
|
||||
import { Between, In, IsNull, Like, Not, Repository } from 'typeorm';
|
||||
import { QueueTicket } from '../../domain/entities/ticket.entity';
|
||||
import {
|
||||
QueueItemModel,
|
||||
|
@ -47,11 +47,8 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
|||
|
||||
async ticketByCode(code: string): Promise<QueueTicketModel[]> {
|
||||
return this.repo.find({
|
||||
relations: ['order'],
|
||||
where: {
|
||||
order: {
|
||||
code,
|
||||
},
|
||||
code: Like(`${code}%`),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ export class QueueOrchestrator {
|
|||
async loginCustomer(id: string): Promise<QueueOrder> {
|
||||
try {
|
||||
const order = await this.dataService.loginQueue(id);
|
||||
const tickets = await this.dataService.ticketByCode(order.code);
|
||||
const code = order.tickets[0].code ?? order.code;
|
||||
const tickets = await this.dataService.ticketByCode(code);
|
||||
order.tickets = tickets;
|
||||
return order;
|
||||
} catch (error) {
|
||||
|
@ -52,7 +53,11 @@ export class QueueOrchestrator {
|
|||
const { name, phone } = login;
|
||||
const now = moment().format('DD/MM/YYYY');
|
||||
try {
|
||||
return await this.dataService.loginPhone(name, phone);
|
||||
const order = await this.dataService.loginPhone(name, phone);
|
||||
const code = order.tickets[0].code ?? order.code;
|
||||
const tickets = await this.dataService.ticketByCode(code);
|
||||
order.tickets = tickets;
|
||||
return order;
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException({
|
||||
message: `Antrian atas nama ${name} dan nomor telepon ${phone} pada tanggal ${now} tidak ditemukan`,
|
||||
|
|
|
@ -32,10 +32,12 @@ export class QueueCondition {
|
|||
if (queues.length == 0) return 0;
|
||||
const calledQueue = queues.filter((q) => q.status === 'called');
|
||||
|
||||
if (calledQueue.length < 1) return 0;
|
||||
|
||||
const times = calledQueue.map((queue) => {
|
||||
return queue.call_time - queue.time;
|
||||
return (queue.call_time - queue.time) / 1000;
|
||||
});
|
||||
|
||||
return math.sum(times) / times.length;
|
||||
return Math.ceil(math.mean(times));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue