From 50404dd481f37e778828dc1d0c5598a8451eedc7 Mon Sep 17 00:00:00 2001 From: Dragos-Paul Strat Date: Wed, 25 Sep 2024 14:47:55 +0300 Subject: [PATCH] feat: [contracts] add correct filters for volunteer contracts with stats --- .../volunteer/repositories/volunteer.repository.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/modules/volunteer/repositories/volunteer.repository.ts b/backend/src/modules/volunteer/repositories/volunteer.repository.ts index 8ce237c0..41f467cc 100644 --- a/backend/src/modules/volunteer/repositories/volunteer.repository.ts +++ b/backend/src/modules/volunteer/repositories/volunteer.repository.ts @@ -21,11 +21,15 @@ import { UpdateVolunteerOptions, VolunteerModelTransformer, } from '../model/volunteer.model'; -import { ContractStatus } from 'src/modules/documents/enums/contract-status.enum'; +import { + ContractStatus, + DocumentContractStatus, +} from 'src/modules/documents/enums/contract-status.enum'; import { ActivityLogStatus } from 'src/modules/activity-log/enums/activity-log-status.enum'; import { ContractEntity } from 'src/modules/documents/entities/contract.entity'; import { ActivityLogEntity } from 'src/modules/activity-log/entities/activity-log.entity'; import { VolunteerProfileEntity } from '../entities/volunteer-profile.entity'; +import { DocumentContractEntity } from 'src/modules/documents/entities/document-contract.entity'; export class VolunteerRepositoryService extends RepositoryWithPagination @@ -268,12 +272,13 @@ export class VolunteerRepositoryService .addSelect((subQuery) => { return subQuery .select('COUNT(contract.id)', 'contractCount') - .from(ContractEntity, 'contract') + .from(DocumentContractEntity, 'contract') .where('contract.volunteerId = :volunteerId', { volunteerId }) .andWhere('contract.status IN (:...statuses)', { statuses: [ - ContractStatus.PENDING_ADMIN, - ContractStatus.PENDING_VOLUNTEER, + DocumentContractStatus.PENDING_VOLUNTEER_SIGNATURE, + DocumentContractStatus.PENDING_NGO_REPRESENTATIVE_SIGNATURE, + DocumentContractStatus.PENDING_APPROVAL_NGO, ], }); }, 'contractCount')