-
Notifications
You must be signed in to change notification settings - Fork 246
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
Row selection for peer reviewer unassigning bypasses current unassign method #7274
Changes from 3 commits
20aa634
8f9f4fc
9b8a554
0395ea2
5897d73
35e93d8
b145503
9f3996e
8bfba79
181ec39
da70fcd
6ae354a
0d6ead5
1226211
942c6c6
625b64d
55f5784
69cf8ef
b770965
fdf1891
712f2c4
873c34e
85c2028
dbba456
53c38c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,23 @@ def assign_groups | |
return | ||
end | ||
when 'unassign' | ||
unless selected_reviewee_group_ids.empty? # if a row was selected | ||
selected_reviewee_group_ids.each do |reviewee_id| # row selected reviewee | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This algorithm is correct but pretty inefficient, as it involves a triply-nested loop. You can improve this in a few ways:
As usual for complex queries, I recommend experimenting in the Rails console first before writing code to modify this method. |
||
selected_reviewer_group_ids.each do |reviewer_id| # selected reviewers on left side | ||
peer_reviews = PeerReview.joins(result: :submission).where(submissions: { grouping_id: reviewee_id }) | ||
peer_reviews.each do |peer_review| # all peer reviews associated with the reviewee | ||
if peer_review.get_reviewer_id.to_s == reviewer_id.to_s | ||
# if the selected reviewer is the reviewer of the peer review | ||
# in other words, if the reviewer is assigned to the reviewee's row | ||
reviewers_to_remove_from_reviewees_map[reviewee_id] ||= {} | ||
reviewers_to_remove_from_reviewees_map[reviewee_id][reviewer_id] = true # mark for unassignment | ||
end | ||
end | ||
end | ||
end | ||
selected_reviewee_group_ids = [] # prevent whole row from being deleted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has been removed! |
||
# now the rest of unassign follows as expected | ||
end | ||
deleted_count, undeleted_reviews = PeerReview.unassign(selected_reviewee_group_ids, | ||
reviewers_to_remove_from_reviewees_map) | ||
if !undeleted_reviews.empty? && deleted_count == 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check isn't necessary (the
.each
below will not execute ifselected_reviewee_group_ids
is empty)