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

#953 - Part 2 Generate review assignments action not auto assign final decision #955

Conversation

nmadruga
Copy link
Contributor

@nmadruga nmadruga commented Nov 7, 2022

Part 2 fix for #953

Front-end: msupply-foundation/conforma-web-app#1428

Briefing of changes

  • Removed action updateReviewAssignmentStatus not needed anymore - since we don't change isLocked for selfAssignments
  • Removed from ENUM assign_actions the column ASSIGN_LOCKED
  • Add new column auto-generated on Graphql calls to set available_sections in ReviewAssignment

Previous description

Changes to action generateReviewAssignments required for FinalDecision to act as any other self-assignable assignment. So only one reviewAssignment should stay as ASSIGNED status. The reviewer has to self-assign first and then start the review. This fix should be resolving the existing bug with #943

I also had to change how isLocked persists. Will need further testing to make sure this is consistent with other states. Not needed now that action updateReviewAssignmentStatus has been fully removed.

Nicole Madruga added 3 commits November 7, 2022 14:05
…nts' into #953-generateReviewAssignments-action-not-auto-assign-final-decision
… as unlocked on unassignment - so the newly asignee is not locked anymore
@omsupply-bot
Copy link

omsupply-bot bot commented Nov 7, 2022

Beep boop! This pull request does not have an associated issue :(.

@nmadruga nmadruga mentioned this pull request Nov 7, 2022
12 tasks
Copy link
Collaborator

@CarlosNZ CarlosNZ left a comment

Choose a reason for hiding this comment

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

Cool, great to see a PR that is mainly removals :)

See my inline comment about the "is_locked" situation.

Copy link
Collaborator

@CarlosNZ CarlosNZ left a comment

Choose a reason for hiding this comment

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

See comments. Looking good though :)

// 1. If existing
// - keep same status, isSelfAssignable
// - just update isLocked = true (if already assigned to another)
// - keep same isLocked if assigned
Copy link
Collaborator

Choose a reason for hiding this comment

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

// - keep same isLocked if assigned

Shouldn't existing review_assignments get isLocked = false always? (assuming this action runs on submission of applications and reviews). Otherwise, when do the "locked" assignments get "unlocked"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. But basically I added one specific case for when one ReviewAssignment was added while in the state of last submitted Review has locked others (LOQ submitted). So for that reason I have also changed updateReviewStatus which will set ReviewAssignment to be locked in this case (and then checked here). Please have a look on these 2 files:

  • plugins/action_generate_review_assignment_records/src/generateReviewAssignments.ts
  • plugins/action_update_review_status/src/updateReviewsStatuses.ts

@@ -461,7 +460,7 @@ See [Grant Permissions](#grant-permissions) above regarding acting on user-only

### Generate Review Assignments

Generates records in the `review_assignment` table -- i.e. which users (reviewers) are allowed to do a review for the current stage/level (and for which Sections). The records are set with `status` "Available" or "Assigned" and flags for `isSelfAssignable` and `isLocked` to help define when is allowed self-assignment.
Generates records in the `review_assignment` table -- i.e. which users (reviewers) are allowed to do a review for the current stage/level (and for which Sections). The records are set with `status` "Available" or "Assigned". With the properties to specify the type of assignament: `isSelfAssignable` if it should show for self-assignment when not assigned by another user. The `isLocked` property helps defining that the review can start but not be submitted - after the application has been back to Applicant for ammendments.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe bullet-point these properties to make easier to read?

Also:

isSelfAssignable if it should show for self-assignment when not assigned by another user.

Isn't "self-assignable" a template configuration? So maybe should say "determines whether this assignment is self-assignable as determined by the template configuration for this stage/level" ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo on assignament => "assignment" ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Done

Nicole Madruga added 2 commits November 8, 2022 16:46
…ns_list_view and add new function to auto-generate column resulting the available_sections for one assignment
database/migration/migrateData.ts Outdated Show resolved Hide resolved
database/migration/migrateData.ts Outdated Show resolved Hide resolved
database/migration/migrateData.ts Outdated Show resolved Hide resolved
database/migration/migrateData.ts Outdated Show resolved Hide resolved
Comment on lines 588 to 589
console.log(' - Update existing review_assignment to set is_locked=false when isSelfAssigned')
// TODO - Not sure how to do this
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if we don't do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. 👍

database/buildSchema/43_views_functions_triggers.sql Outdated Show resolved Hide resolved
database/buildSchema/43_views_functions_triggers.sql Outdated Show resolved Hide resolved
…ssignments-action-not-auto-assign-final-decision
Fix mistake in review_assignment validity trigger
@CarlosNZ CarlosNZ force-pushed the #953-generateReviewAssignments-action-not-auto-assign-final-decision branch from 3827593 to 52ce0d8 Compare November 9, 2022 04:03
@CarlosNZ
Copy link
Collaborator

CarlosNZ commented Nov 9, 2022

Okay, @nmadruga I've updated and fixed a bunch of those things so we could get this branch working. Can see my changes in 52ce0d8

I've marked all the comments "Resolved" that I've taken care off -- you can show them again if you want to see what they were. So the only comments still visible should be minor things or questions for you to take a look at. The only one that seems fairly important is this one.

Nicole Madruga added 5 commits November 10, 2022 12:42
… LOQ so any other ReviewAssignments created also are locked at that point.
…ed from Applicant to be used as model for new ReviewAssignments created after that (so those wouldn't generate an unlocked assignment in the same level/stage)
@nmadruga
Copy link
Contributor Author

Okay, @nmadruga I've updated and fixed a bunch of those things so we could get this branch working. Can see my changes in 52ce0d8

I've marked all the comments "Resolved" that I've taken care off -- you can show them again if you want to see what they were. So the only comments still visible should be minor things or questions for you to take a look at. The only one that seems fairly important is this one.

Looks good!

Thanks Carl, I have made suggestions. Please just note the changes flagged on this comment, I'm happy to merge if you are ok with that. Although I haven't got much further with testing this changes yet

@@ -92,10 +92,23 @@ const updateReviewsStatuses: ActionPluginType = async ({
ReviewStatus.Draft,
])

// Lock ReviewAssignment of Review subimmet as changes required to applicant
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Lock ReviewAssignment of Review subimmet as changes required to applicant
// Lock ReviewAssignment of Review submitted as changes required to applicant

Comment on lines 4 to 19
getReview: async (reviewId: number) => {
const text = `
SELECT
review_assignment_id AS "reviewAssignmentId"
FROM review
WHERE id = $1
`

try {
const result = await DBConnect.query({ text, values: [reviewId] })
return result.row[0]
} catch (err) {
console.log(err.message)
throw err
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why we need an extra database call. We already fetched all the associated reviews at the beginning, you should be able to pull it out of that result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverting this - as per convo in person

Also - I'll be adding a briefing issue on what we have agreed on

…eReviewStatuses. isLocked logic as it is currently. And new ReviewAssignments gets created always as isLocked = false
Copy link
Collaborator

@CarlosNZ CarlosNZ left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks.

@nmadruga nmadruga merged commit cc7f7d7 into feature/final-decision-fixes Nov 10, 2022
@nmadruga nmadruga deleted the #953-generateReviewAssignments-action-not-auto-assign-final-decision branch November 10, 2022 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants