fix: queue bucket item id
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

pull/115/head 20.2.10-alpha.4
shancheas 2024-11-06 12:01:49 +07:00
parent 28c1ab36da
commit bf5914af92
2 changed files with 16 additions and 2 deletions

View File

@ -93,6 +93,9 @@ export class ItemModel
@JoinColumn({ name: 'item_queue_id' }) @JoinColumn({ name: 'item_queue_id' })
item_queue: ItemQueueModel; item_queue: ItemQueueModel;
@Column('varchar', { name: 'item_queue_id', nullable: true })
item_queue_id: string;
// relation ke tenant // relation ke tenant
// ? karena item bisajadi merupakan item dari tenant // ? karena item bisajadi merupakan item dari tenant
@Column('varchar', { name: 'tenant_id', nullable: true }) @Column('varchar', { name: 'tenant_id', nullable: true })

View File

@ -6,12 +6,16 @@ import { Between, Repository } from 'typeorm';
import { BaseReadService } from 'src/core/modules/data/service/base-read.service'; import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
import { QueueBucketModel } from '../models/queue-bucket.model'; import { QueueBucketModel } from '../models/queue-bucket.model';
import * as moment from 'moment'; import * as moment from 'moment';
import { QueueItemModel } from '../models/queue.model';
@Injectable() @Injectable()
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> { export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
constructor( constructor(
@InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT) @InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
private repo: Repository<QueueBucketModel>, private repo: Repository<QueueBucketModel>,
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
private item: Repository<QueueItemModel>,
) { ) {
super(repo); super(repo);
} }
@ -20,9 +24,16 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
const start = moment().startOf('day').valueOf(); const start = moment().startOf('day').valueOf();
const end = moment().endOf('day').valueOf(); const end = moment().endOf('day').valueOf();
const queueItem = await this.item.findOne({
relations: ['item'],
where: {
id: item_id,
},
});
const queue = await this.repo.findOne({ const queue = await this.repo.findOne({
where: { where: {
queue_item_id: item_id, queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
date: Between(start, end), date: Between(start, end),
}, },
}); });
@ -31,7 +42,7 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
const regularNumber = vip ? 0 : 1; const regularNumber = vip ? 0 : 1;
const vipNumber = vip ? 1 : 0; const vipNumber = vip ? 1 : 0;
this.repo.save({ this.repo.save({
queue_item_id: item_id, queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
date: start, date: start,
regular: regularNumber, regular: regularNumber,
vip: vipNumber, vip: vipNumber,