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

#2180 - Queued Assessments - Assessment Workflow Enqueuer Scheduler - Start Assessment (Part 1) #2285

Merged
merged 17 commits into from
Sep 12, 2023

Conversation

andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Sep 8, 2023

  • Created the new queue configuration for the scheduler, executed every 30 seconds, and cleaned up every 24 hours.
  • Removed from the code the points where the queue to start the workflow was invoked. From now on only the scheduler will invoke the workflow start queue.
    • Method startAssessment removed since it is no longer needed.
    • Method hasIncompleteAssessment and assertAllAssessmentsCompleted removed since there is no purpose anymore.
    • Multiple workflows can now be saved and the scheduler will coordinate their execution.
  • StartApplicationAssessment queue can now be started without providing the workflowName.
  • Created a migration to update the assessment status based on assessment_workflow_id, and assessment_data. The rollback is less meaningful and it was created to try to bring the column back to its original state where the column was set with its default value Submitted.

TODO:

  • E2E tests
  • Logs
    • Move ProcessSummaryResult from integrations to lib to allow its use outside integrations.

@andrewsignori-aot andrewsignori-aot added Queue Consumers DB DB migration involved Camunda Worflow Involves camunda workflow changes labels Sep 8, 2023
@andrewsignori-aot andrewsignori-aot self-assigned this Sep 8, 2023
@andrewsignori-aot andrewsignori-aot changed the title #2180 - Queued Assessments - Assessment Workflow Enqueuer Scheduler - Start Assessment (Part 1) #2180 - Queued Assessments - Assessment Workflow Enqueuer Scheduler - Start Assessment (Part 1) Sep 8, 2023
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 some questions.

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.

Good work @andrewsignori-aot 👍 Thanks for the explanation.

AND sims.applications.application_status NOT IN (
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍


@Process()
async startAssessment(job: Job<StartAssessmentQueueInDTO>) {
let workflowName = job.data.workflowName;
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

)
.getQuery();
return (
this.applicationRepo
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering, this query could have come from student assessments instead of applications right? so that it will just return the assesments(assessment id) which needs to be processed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True. It was originally designed to allow the later update of the application + assessment together but it did not work as expected and I ended up doing the individual updates in a transaction.
Right now the only benefit is that it makes it pretty easy to have the assessments grouped to allow the processing and also pick the next assessment to be processed if multiple exists under the same application.

currentProcessingAssessment: { id: nextAssessment.id },
});
if (!applicationUpdateResult.affected) {
throw new Error("Application update did not affected any records.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error message could be more specific e.g. currentProcessingAssessment id was already set or incorrect application id. something like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That log itself may not provide the entire picture, but please check below the logs around it. As shown below there is some additional info that would make it easier to have it traced.

About the suggestions:

  • "currentProcessingAssessment id was already set" would not be accurate.
  • "incorrect application id" can be checked using the additional logs also.

Queueing next pending assessment for application id 123.
Found 2 pending assessment(s). Queueing assessment 999.
Associating application currentProcessingAssessment as assessment id 999.
(...)
Application update did not affected any records.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the way, planning to do some logging improvement in the next PR.

});
if (!assessmentUpdateResults.affected) {
throw new Error(
"Student assessment update did not affected any records.",
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 Author

Choose a reason for hiding this comment

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

@dheepak-aot
Copy link
Collaborator

Great job with creating the queue to process assessments. Great to see the depth of analysis and considerations involved in the effort. Thanks for explaining the issue with migrations. Please have a look at the comments.

@sonarqubecloud
Copy link

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 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.54% ( 2181 / 12437 )
Methods: 8.02% ( 126 / 1572 )
Lines: 20.32% ( 1917 / 9432 )
Branches: 9.63% ( 138 / 1433 )

@github-actions
Copy link

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

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 67.54% ( 437 / 647 )
Methods: 58.02% ( 47 / 81 )
Lines: 69.93% ( 386 / 552 )
Branches: 28.57% ( 4 / 14 )

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 explanation.

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 54.48% ( 3995 / 7333 )
Methods: 51.31% ( 488 / 951 )
Lines: 59.3% ( 3245 / 5472 )
Branches: 28.79% ( 262 / 910 )

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.

Thanks for making the changes 👍

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Camunda Worflow Involves camunda workflow changes DB DB migration involved Queue Consumers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants