fix: total QR header
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

pull/115/head 1.2.7-alpha.3
shancheas 2024-11-20 17:33:00 +07:00
parent 3b7d7ea80b
commit 1148a72481
3 changed files with 13 additions and 9 deletions

View File

@ -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}%`),
},
});
}

View File

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

View File

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