-
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
Row selection for peer reviewer unassigning bypasses current unassign method #7274
Conversation
…imilar logic to Graders tab
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure selected_reviewee_group_ids
can be removed from the PeerReview.unassign()
call.
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.
It has been removed!
…ixed case of row selction and individual reviewer selection
Pull Request Test Coverage Report for Build 12104886027Details
💛 - Coveralls |
@@ -157,8 +157,23 @@ def assign_groups | |||
return | |||
end | |||
when 'unassign' | |||
deleted_count, undeleted_reviews = PeerReview.unassign(selected_reviewee_group_ids, | |||
reviewers_to_remove_from_reviewees_map) | |||
unless selected_reviewee_group_ids.empty? # if a row was selected |
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 if selected_reviewee_group_ids
is empty)
|
||
context 'when applicable reviewers are selected' do | ||
before do | ||
@selected_reviewee_group_ids.each do |reviewee_id| |
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 block shouldn't be what you want (it doesn't make sense to mix reviewer group ids with reviewee group ids)
spec/models/peer_review_spec.rb
Outdated
@@ -89,7 +89,7 @@ | |||
end | |||
end | |||
|
|||
describe '#has_marks_or_annotations?' do | |||
describe 'has_marks_or_annotations?' do |
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 change isn't correct; the #
indicates that this is an instance method, as a Ruby convention
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.
self.get_num_marked
and self.get_num_collected
are marked with self.
, which from my knowledge, makes them class methods rather than instance methods. However, their corresponding test cases are also prefixed with #
. Which naming convention should these test cases follow?
deleted_count, undeleted_reviews = PeerReview.unassign(selected_reviewee_group_ids, | ||
reviewers_to_remove_from_reviewees_map) | ||
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 comment
The 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:
- First, by joining on relevant
PeerReview
associations, which in this case are:reviewer
andreviewee
(both of these refer toGrouping
s, but Rails will handle the SQL generation to avoid name conflicts---inspect the logged SQL query for more information) - You can use
where
on those associations, e.g..where(reviewer: { id: ... })
and again Rails will produce the correct query - You can pass in an array of ids to a
where
condition, and the resulting SQL query become anIN
operation
As usual for complex queries, I recommend experimenting in the Rails console first before writing code to modify this method.
…justed controller tests for row selection case to correctly map reviewer ids based on the assigned reviewers through a database lookup
…justed controller tests for row selection case to correctly map reviewer ids based on the assigned reviewers through a database lookup
… peer-review-unassign-row-selection
Marking as "ready for review" to see how ci/cd tests run, still not 100% on these changes. Will re-request a review once I am ready for your review :) |
… peer-review-unassign-row-selection
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.
@hemmatio nice work. I left a few comments for further improvement, but I think you're quite close. Also make sure to update the Changelog (this is indicated in the PR template checklist, which you should remember to fill out)
@@ -112,8 +112,8 @@ def show_result | |||
|
|||
def assign_groups | |||
@assignment = Assignment.find(params[:assignment_id]) | |||
selected_reviewer_group_ids = params[:selectedReviewerGroupIds] || [] | |||
selected_reviewee_group_ids = params[:selectedRevieweeGroupIds] || [] | |||
selected_reviewer_group_ids = Array(params[:selectedReviewerGroupIds]) || [] |
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.
I'm not sure why adding Array
is needed here, as this PR isn't changing the front-end at all? If you're having trouble with the tests you've added, you can call Array
in the tests themselves.
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.
reviewers_to_remove_from_reviewees_map) | ||
peer_reviews_filtered = PeerReview.joins(:reviewer, :reviewee) | ||
.where(reviewer: { id: selected_reviewer_group_ids }) | ||
.where(reviewee: { id: selected_reviewee_group_ids }) |
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.
Also, these don't need to be separate where
clauses, as .where
takes an arbitrary number of arguments and treats them as an AND
, which is what you want in this case
… peer-review-unassign-row-selection
… as their respective tests
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.
@hemmatio great work!
By the way, I missed your earlier question about naming conventions for tests: the #
symbol is used to prefix instance method names; the .
is used to prefix class method names. Somewhat confusingly, class methods are defined using "self":
class A:
def my_instance_method # no "self"
...
end
def self.my_class_method # "self" indicates this is a class method
...
end
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
When selecting an entire row, the necessary checks from #7263 are being bypassed. For reference, an image of "row selection":
Proposed fix: make the row-selected behaviour consistent with the behaviour from the Graders tab.
An image of the Graders tab is as follows:

...
Screenshots of your changes (if applicable)
Examples of acceptable selections for unassignment:Associated documentation repository pull request (if applicable)
Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)
14/11/24: I've gone through and replicated the Graders tab logic for the row selection case. I still need to add tests.
19/11/24: Tests have been added for various row selection cases. I have removed the method
delete_all_reviews_for()
in thePeerReview
class, as well as all calls for it within the peer review unassign logic, as it is not useful.