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