import { Injectable } from '@nestjs/common';

import { InjectRepository } from '@nestjs/typeorm';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
import { Repository } from 'typeorm';
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
import { QueueBucketModel } from '../models/queue-bucket.model';

@Injectable()
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
  constructor(
    @InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
    private repo: Repository<QueueBucketModel>,
  ) {
    super(repo);
  }

  getQueue(item_id: string): Promise<QueueBucketModel> {
    return this.repo.findOne({
      where: {
        queue_item_id: item_id,
      },
    });
  }
}
