-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Independent Study. Creating use of bullet gem and .includes to speed up db accesses #2171
Conversation
Hey @harshkachhadia, TravisCI finished with status |
Generated by expertiza-bot |
Gemfile.lock
Outdated
@@ -698,4 +703,4 @@ DEPENDENCIES | |||
zip-zip | |||
|
|||
BUNDLED WITH | |||
1.16.6 | |||
1.17.3 |
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.
please run bundle with 1.16.6
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.
Done.
@@ -44,12 +44,14 @@ def self.get_user_list(user) | |||
participants << course.get_participants | |||
end | |||
assignments = Assignment.where(instructor_id: user.id) | |||
assignments.each do |assignment| | |||
#Line 48 implements eager loading using 'includes' method. For detail, visit: http://tiny.cc/9aomuz | |||
assignments.includes([:participants]).each do |assignment| | |||
participants << assignment.participants | |||
end | |||
participants.each do |p_s| |
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.
refactor p_s to participant. variable name is unclear
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.
The only change we made in line 5 was to add
.includes([:participants]) + comment
other than this, all the code is as it was before. I am assuming it should be fine as it was already there in the beta branch before we even started working.
@@ -1,7 +1,8 @@ | |||
<%# this page will display the notifications as a flash message Randal Myers, 22 March 2017 %> | |||
|
|||
<% course_ids = [] %> | |||
<% current_user.participants.each{|p| course_ids << p.assignment.course.id if p.assignment and p.assignment.course} %> | |||
<%#Line 5 implements eager loading using 'includes' method. For detail, visit: http://tiny.cc/9aomuz%> | |||
<% current_user.participants.includes(:assignment, assignment: [:course]).each{|p| course_ids << p.assignment.course.id if p.assignment and p.assignment.course} %> |
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.
use && instead of and
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.
The only change we made in line 5 was to add
.includes(:assignment, assignment: [:course]) + comment
other than this, all the code is as it was before. I am assuming it should be fine as it was already there in the beta branch before we even started working.
config/environments/development.rb
Outdated
Bullet.alert = true | ||
Bullet.bullet_logger = true | ||
Bullet.console = true | ||
Bullet.rails_logger = true |
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.
do we need to be logging these when we merge this project in?
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.
We won't need logging when we merge. I will turn all these to 'false'. This configuration is for 'bullet gem', which helps in detecting N+1 problems in the application using logging. This can be later turned to 'true' if someone wishes to find and resolve N+1 issues in future codebase.
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.
fix gems
no_proxy_fix (0.1.2) | ||
nokogiri (1.9.1) | ||
nokogiri (1.10.10) |
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 needs to be usable with ruby version 2.2.7
Project Description
Link to Wiki
Team
Dr. Edward Gehringer(efg)(mentor)