Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEN - 946 Sync now ignores BCCNM milestones #684

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions apps/api/src/applicant/external-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from 'typeorm';
import dayjs from 'dayjs';
import _ from 'lodash';
import { AtsApplicant, Authorities, STATUS, StatusCategory } from '@ien/common';
import { AtsApplicant, Authorities, BCCNM_NEW_FIELDS, STATUS, StatusCategory } from '@ien/common';
import { ExternalRequest } from 'src/common/external-request';
import { AppLogger } from 'src/common/logger.service';
import { IENApplicant } from './entity/ienapplicant.entity';
Expand Down Expand Up @@ -378,6 +378,10 @@ export class ExternalAPIService {
manager: EntityManager,
): Promise<number> {
let removedCount = 0;
const statuses = await this.ienapplicantStatusRepository.find();
const bccnm_new_statuses = statuses.filter(value =>
BCCNM_NEW_FIELDS.some(bccnm_new_field => value.status === bccnm_new_field.toString()),
);
await Promise.all(
applicants.map(async a => {
const audits: { id: string; status_id: string }[] = await manager.query(`
Expand All @@ -386,7 +390,8 @@ export class ExternalAPIService {
INNER JOIN "ien_applicant_status" "status" ON "status"."id" = "audit"."status_id"
WHERE
"audit"."applicant_id" = '${a.applicant_id.toLowerCase()}' AND
"status"."category" != 'IEN Recruitment Process';
"status"."category" != 'IEN Recruitment Process' AND
"status"."id" NOT IN ('${bccnm_new_statuses.map(status => status.id).join("','")}')
`);

if (!audits?.length) return;
Expand Down Expand Up @@ -468,7 +473,7 @@ export class ExternalAPIService {
['id'],
);
this.logger.log(
`Signed Return of Service Agreement milestones updated: ${result.raw.length}`,
`Signed Return of Service Agreement milestones updated: ${result?.raw?.length}`,
'ATS-SYNC',
);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/enum/milestone-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export enum STATUS {
END_OF_JOURNEY_COMPLETE = 'End of Journey - Journey Complete',
END_OF_JOURNEY_INCOMPLETE = 'End of Journey - Journey Incomplete',
}
export const BCCNM_NEW_FIELDS = [
STATUS.BCCNM_APPLICATION_COMPLETE_DATE,
STATUS.BCCNM_DECISION_DATE,
STATUS.BCCNM_REGISTRATION_DATE,
];

export const COMPLETED_STATUSES = [
STATUS.PRE_SCREEN_NOT_PASSED,
Expand Down
Loading