feat: fix
This commit is contained in:
@@ -5,6 +5,7 @@ import { IsNull, Repository } from "typeorm";
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { GetSupportPlanListQueryDto } from "../DTO/get-support-plan-list-query.dto";
|
||||
import { SupportPlan } from "../entities/support-plan.entity";
|
||||
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
||||
|
||||
@Injectable()
|
||||
export class SupportPlanRepository extends Repository<SupportPlan> {
|
||||
@@ -16,7 +17,9 @@ export class SupportPlanRepository extends Repository<SupportPlan> {
|
||||
async getSupportPlansListAdmin(queryDto: GetSupportPlanListQueryDto) {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
const query = this.createQueryBuilder("supportPlan").where("supportPlan.deletedAt IS NULL");
|
||||
query.loadRelationCountAndMap("supportPlan.userCount", "supportPlan.users");
|
||||
query.loadRelationCountAndMap("supportPlan.userCount", "supportPlan.users", "user", (qb) =>
|
||||
qb.where("user.status = :status", { status: UserSupportPlanStatus.ACTIVE }),
|
||||
);
|
||||
|
||||
if (queryDto.q) {
|
||||
query.andWhere("supportPlan.name ILIKE :q OR supportPlan.description ILIKE :q", { q: `%${queryDto.q}%` });
|
||||
@@ -29,7 +32,7 @@ export class SupportPlanRepository extends Repository<SupportPlan> {
|
||||
query.skip(skip).take(limit).orderBy("supportPlan.createdAt", "DESC");
|
||||
return query.getManyAndCount();
|
||||
}
|
||||
|
||||
//***************************************** */
|
||||
async getSupportPlansListUser() {
|
||||
return this.createQueryBuilder("supportPlan")
|
||||
.leftJoinAndSelect("supportPlan.features", "features")
|
||||
|
||||
@@ -25,6 +25,23 @@ export class UserSupportPlanRepository extends Repository<UserSupportPlan> {
|
||||
return this.findAndCount({
|
||||
where: { supportPlan: { id: supportPlanId }, status: UserSupportPlanStatus.ACTIVE },
|
||||
relations: { user: true, supportPlan: true },
|
||||
select: {
|
||||
id: true,
|
||||
user: {
|
||||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
},
|
||||
supportPlan: {
|
||||
id: true,
|
||||
name: true,
|
||||
price: true,
|
||||
},
|
||||
startDate: true,
|
||||
endDate: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
},
|
||||
take: limit,
|
||||
skip,
|
||||
});
|
||||
|
||||
@@ -127,8 +127,6 @@ export class TicketsService {
|
||||
const ticketLimit = parseInt(ticketLimitFeature.featureValue);
|
||||
if (isNaN(ticketLimit)) return;
|
||||
|
||||
if (isNaN(ticketLimit)) throw new BadRequestException(TicketMessageEnum.INVALID_TICKET_LIMIT);
|
||||
|
||||
const today = dayjs().startOf("day").toDate();
|
||||
|
||||
const ticketCount = await queryRunner.manager.count(this.ticketsRepository.target, {
|
||||
|
||||
Reference in New Issue
Block a user