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

Refactor on_the_fly_calc #2039

Merged
merged 7 commits into from Sep 21, 2021

Conversation

nnhimes
Copy link
Collaborator

@nnhimes nnhimes commented Sep 12, 2021

Refactoring on_the_fly_calc.rb to be in assignment_helper.rb

The file has 7 methods: 3 that are exclusively called as assignment instance methods, and 4 that are called internally to help facilitate those 3. The name on_the_fly_calc no longer made sense, and it belongs in helpers

@expertiza-bot
Copy link
Contributor

1 Message
💬 Thanks for the pull request, and welcome! 🎉 The Expertiza team is excited to review your changes, and you should hear from us soon.

This repository is being automatically checked for code quality issues using Code Climate.
You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a pull request is considered ready to review.

If you have any questions, please send email to expertiza-support@lists.ncsu.edu.

Generated by expertiza-bot

@coveralls
Copy link

Coverage Status

Coverage decreased (-18.6%) to 38.109% when pulling edf17fb on nnhimes:Refactor-on_the_fly_calc into 481ded3 on expertiza:beta.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-18.6%) to 38.109% when pulling edf17fb on nnhimes:Refactor-on_the_fly_calc into 481ded3 on expertiza:beta.

@coveralls
Copy link

coveralls commented Sep 12, 2021

Coverage Status

Coverage increased (+10.09%) to 66.846% when pulling 9f18f67 on nnhimes:Refactor-on_the_fly_calc into 481ded3 on expertiza:beta.

@nnhimes
Copy link
Collaborator Author

nnhimes commented Sep 14, 2021

Tested on virtualbox - no errors that I could find when editing assignments, creating new ones, or viewing them as a student.

Expected, since the only real change was the module names and file locations. When methods from the new assignment_score_helper module are called, they are still called on assignment instances. Assignment simply includes the entire module and its methods. Low-risk refactor

app/models/assignment.rb Outdated Show resolved Hide resolved
end

def compute_reviews_hash
@review_scores = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are these being passed as instance variables, can you refactor all of this into using parameters

contributors.each do |contributor|
questions = peer_review_questions_for_team(contributor, round)
assessments = ReviewResponseMap.assessments_for(contributor)
assessments = assessments.select {|assessment| assessment.round == round }
Copy link
Collaborator

Choose a reason for hiding this comment

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

use select!{ |assessment| assessment.round == round}

# Get all of the questions asked during peer review for the given team's work
def peer_review_questions_for_team(team, round_number = nil)
topic_id = SignedUpTeam.find_by(team_id: team.id).topic_id unless team.nil? or SignedUpTeam.find_by(team_id: team.id).nil?
review_questionnaire_id = review_questionnaire_id(round_number, topic_id) unless team.nil? or SignedUpTeam.find_by(team_id: team.id).nil?
Copy link
Collaborator

Choose a reason for hiding this comment

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

use || instead of or


# Get all of the questions asked during peer review for the given team's work
def peer_review_questions_for_team(team, round_number = nil)
topic_id = SignedUpTeam.find_by(team_id: team.id).topic_id unless team.nil? or SignedUpTeam.find_by(team_id: team.id).nil?
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are literally the same checks so just clean this up

app/helpers/assignment_helper.rb Outdated Show resolved Hide resolved
@expertiza-travisci-bot
Copy link

Hey @nnhimes,
Your changes look good to me! 🎉

Copy link
Collaborator

@johnbumgardner johnbumgardner left a comment

Choose a reason for hiding this comment

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

LGTM

@johnbumgardner johnbumgardner merged commit 5bd0790 into expertiza:beta Sep 21, 2021
@duhaoze11 duhaoze11 mentioned this pull request Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants