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

#2183 - Queued Assessments - Assessment Gateway Changes #2245

Conversation

andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Aug 31, 2023

  • Renamed method associateWorkflowId to associateWorkflowInstance to include the part of the process to update the status to "In progress".
  • Added a check to prevent the associateWorkflowInstance from being executed with an unexpected status (see comments in code).
  • Updated assessment status to "Completed" during workflow wrap up task.
  • Added missing audit information.
  • Created a helper method to get a friendly message from the CustomNamedError.
  • Changed the job result to cancel the workflow if the assessment is no longer in the expected status or it there is already another workflow id associated with it.

Comment on lines 75 to 93
if (!assessment.assessmentWorkflowId) {
// Assessment is available to be associated with the workflow instance id.
await assessmentRepo.update(assessmentId, { assessmentWorkflowId });
const now = new Date();
await assessmentRepo.update(assessmentId, {
assessmentWorkflowId,
studentAssessmentStatus: StudentAssessmentStatus.InProgress,
studentAssessmentStatusUpdatedOn: now,
modifier: auditUser,
updatedAt: now,
});
return;
}
if (assessment.assessmentWorkflowId !== assessmentWorkflowId) {
throw new CustomNamedError(
`The assessment is already associated with another workflow instance. Current associated instance id ${assessment.assessmentWorkflowId}.`,
ASSESSMENT_INVALID_OPERATION_IN_THE_CURRENT_STATE,
ASSESSMENT_ALREADY_ASSOCIATED_WITH_DIFFERENT_WORKFLOW,
);
}
// The workflow was already associated with the workflow, no need to update it again.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this part could refactored to put all the validations before the association like in:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so, I will take a look 😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method refactored, please take a look 😉

* in the format "Message (ERROR_CODE).".
* @returns user friendly error message.
*/
getSummaryMessage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Left a question.

// Check if the assessment is in one of the initial statuses. Any status different than "Submitted" and "Queued" should
// cancel the workflow because there is no point executing it.
// A workflow in these statuses can be associated and updated to "In progress" nicely. The expectation is that it would
// be primarily "Queued" but there is no harm in allowing "Submitted" also.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering submitted here is to keep the option of starting the assessments manually for any troubleshooting purpose if required right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. The concern here was more about not allowing the association to other statuses.

* in the format "Message (ERROR_CODE).".
* @returns user friendly error message.
*/
getSummaryMessage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type to signature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the return type.

@dheepak-aot
Copy link
Collaborator

Nice work @andrewsignori-aot . Minor comment and a clarification.

job.variables.assessmentId,
job.processInstanceKey,
);
jobLogger.log("Associated the assessment id.");
logger.log("Associated the assessment id.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to update the log content too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed as below to add more context too.
image

@@ -102,7 +102,7 @@ export class DisbursementController {
await this.disbursementScheduleService.associateMSFAANumber(
job.variables.assessmentId,
);
jobLogger.error("Associated the MSFAA number to the disbursements.");
jobLogger.log("Associated the MSFAA number to the disbursements.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

throw new CustomNamedError(
`The assessment is already associated with another workflow instance. Current associated instance id ${assessment.assessmentWorkflowId}.`,
ASSESSMENT_INVALID_OPERATION_IN_THE_CURRENT_STATE,
`The assessment is already associated to the workflow.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes?

workflowData,
studentAssessmentStatus: StudentAssessmentStatus.Completed,
studentAssessmentStatusUpdatedOn: now,
modifier: auditUser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Good work @andrewsignori-aot . approving the PR as the added comments are very minor

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Copy link
Collaborator

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work @andrewsignori-aot

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the refactoring!

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.94% ( 2177 / 12138 )
Methods: 8.16% ( 126 / 1544 )
Lines: 20.8% ( 1913 / 9195 )
Branches: 9.86% ( 138 / 1399 )

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 46.73% ( 300 / 642 )
Methods: 40% ( 32 / 80 )
Lines: 51.02% ( 251 / 492 )
Branches: 24.29% ( 17 / 70 )

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 72.5% ( 406 / 560 )
Methods: 63.38% ( 45 / 71 )
Lines: 74.53% ( 357 / 479 )
Branches: 40% ( 4 / 10 )

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

E2E SIMS API Coverage Report

Totals Coverage
Statements: 53.27% ( 3931 / 7379 )
Methods: 49.48% ( 472 / 954 )
Lines: 58.32% ( 3210 / 5504 )
Branches: 27.04% ( 249 / 921 )

@andrewsignori-aot andrewsignori-aot merged commit 09acccc into main Sep 1, 2023
@andrewsignori-aot andrewsignori-aot deleted the feature/#2183-queued-assessments-assessment-gateway-changes branch September 1, 2023 21:46
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:56 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:57 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:57 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:57 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:57 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:58 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV September 1, 2023 21:58 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants