Skip to content

Commit

Permalink
fix eoj flash not showing update
Browse files Browse the repository at this point in the history
  • Loading branch information
c1495616js committed Dec 12, 2024
1 parent 1067f05 commit 82fbd02
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
39 changes: 17 additions & 22 deletions apps/api/src/applicant/endofjourney.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,21 @@ export class EndOfJourneyService implements OnModuleInit {
`Setting end of journey incomplete: ${STATUS.NOT_PROCEEDING}. Number of lists: ${list.length}`,
'END-OF-JOURNEY',
);
const results = [];
for (const applicant of list) {
// update the end_of_journey_flag and updated_date of the applicant
let query = this.getIncompleteQuery(manager, applicant.applicant_id);
query = this.checkReEngagedStatusForEoJIncompleteQuery(query);
const results = await Promise.all(
list.map(applicant => {
let query = this.getIncompleteQuery(manager, applicant.applicant_id);
query = this.checkReEngagedStatusForEoJIncompleteQuery(query);

return query
.update('ien_applicants')
.set({
end_of_journey: END_OF_JOURNEY_FLAG.JOURNEY_INCOMPLETE,
updated_date: dayjs().tz('America/Los_Angeles').toDate(),
})
.execute();
}),
);

const result = await query
.update('ien_applicants')
.set({
end_of_journey: END_OF_JOURNEY_FLAG.JOURNEY_INCOMPLETE,
updated_date: dayjs().tz('America/Los_Angeles').toDate(),
})
.execute();
results.push(result);
}
this.logger.log({ results }, 'END-OF-JOURNEY');
};
getIncompleteQuery(
Expand Down Expand Up @@ -315,25 +315,20 @@ export class EndOfJourneyService implements OnModuleInit {
* Event handler for delete re-engaged applicants
*/
@OnEvent(`${SystemMilestoneEvent.REENGAGED}.*`)
async handleReEngagedDeleteEvent(
async handleReEngagedEvent(
payload: IENApplicantStatusAudit,
event: SystemMilestoneEvent,
manager: EntityManager,
): Promise<void> {
this.logger.log(`Handling re-engaged event: ${event}`, 'END-OF-JOURNEY');

const connection = this.connection;
if (!connection) {
if (!manager) {
this.logger.error('Connection failed', 'END-OF-JOURNEY');
return;
}
const queryRunner = connection.createQueryRunner();
await queryRunner.startTransaction();
const manager = queryRunner.manager;

await this.handleReEngagedForJourneyComplete(manager, payload);
await this.handleReEngagedForJourneyIncomplete(manager, payload);

await queryRunner.commitTransaction();
}

private async handleReEngagedForJourneyComplete(
Expand Down
30 changes: 19 additions & 11 deletions apps/api/src/applicant/ienapplicant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,17 @@ export class IENApplicantService {
});
// handle update re-engaged
if (status_audit.status.status === STATUS.RE_ENGAGED) {
this.eventEmitter.emit(
await this.eventEmitter.emitAsync(
SystemMilestoneEvent.CREATE_REENGAGED,
status_audit,
SystemMilestoneEvent.CREATE_REENGAGED,
manager,
);
// await this.eojService.handleReEngagedEvent(
// status_audit,
// SystemMilestoneEvent.CREATE_REENGAGED,
// manager,
// );
}
return status_audit;
});
Expand Down Expand Up @@ -418,16 +424,17 @@ export class IENApplicantService {
[audit.applicant.id],
manager,
);
});

// handle update re-engaged
if (audit.status.status === STATUS.RE_ENGAGED) {
this.eventEmitter.emit(
SystemMilestoneEvent.UPDATE_REENGAGED,
audit,
SystemMilestoneEvent.UPDATE_REENGAGED,
);
}
// handle update re-engaged
if (audit.status.status === STATUS.RE_ENGAGED) {
await this.eventEmitter.emitAsync(
SystemMilestoneEvent.UPDATE_REENGAGED,
audit,
SystemMilestoneEvent.UPDATE_REENGAGED,
manager,
);
}
});

return audit;
}
Expand Down Expand Up @@ -463,10 +470,11 @@ export class IENApplicantService {

// handle delete re-engaged
if (status.status.status === STATUS.RE_ENGAGED) {
this.eventEmitter.emit(
await this.eventEmitter.emitAsync(
SystemMilestoneEvent.DELETE_REENGAGED,
status,
SystemMilestoneEvent.DELETE_REENGAGED,
manager,
);
}
});
Expand Down

0 comments on commit 82fbd02

Please sign in to comment.