fix: queue bucket item id
parent
28c1ab36da
commit
bf5914af92
|
@ -93,6 +93,9 @@ export class ItemModel
|
|||
@JoinColumn({ name: 'item_queue_id' })
|
||||
item_queue: ItemQueueModel;
|
||||
|
||||
@Column('varchar', { name: 'item_queue_id', nullable: true })
|
||||
item_queue_id: string;
|
||||
|
||||
// relation ke tenant
|
||||
// ? karena item bisajadi merupakan item dari tenant
|
||||
@Column('varchar', { name: 'tenant_id', nullable: true })
|
||||
|
|
|
@ -6,12 +6,16 @@ import { Between, Repository } from 'typeorm';
|
|||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||
import { QueueBucketModel } from '../models/queue-bucket.model';
|
||||
import * as moment from 'moment';
|
||||
import { QueueItemModel } from '../models/queue.model';
|
||||
|
||||
@Injectable()
|
||||
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
||||
constructor(
|
||||
@InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<QueueBucketModel>,
|
||||
|
||||
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
||||
private item: Repository<QueueItemModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
|
@ -20,9 +24,16 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
|||
const start = moment().startOf('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({
|
||||
where: {
|
||||
queue_item_id: item_id,
|
||||
queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
|
||||
date: Between(start, end),
|
||||
},
|
||||
});
|
||||
|
@ -31,7 +42,7 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
|||
const regularNumber = vip ? 0 : 1;
|
||||
const vipNumber = vip ? 1 : 0;
|
||||
this.repo.save({
|
||||
queue_item_id: item_id,
|
||||
queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
|
||||
date: start,
|
||||
regular: regularNumber,
|
||||
vip: vipNumber,
|
||||
|
|
Loading…
Reference in New Issue