Feature #42589
closed
Optimize watchers list rendering by eager loading email addresses
Added by Go MAEDA about 1 month ago.
Updated 25 days ago.
Description
When the "Use Gravatar user icons" setting is enabled, viewing an issue causes one query per watcher to load their email address. This patch reduces the number of database queries by eager loading email_address for the watcher users.
Files
- Target version changed from Candidate for next major release to 5.1.8
Setting the target version to 5.1.8.
- Target version deleted (
5.1.8)
The patch causes an error when the watcher list contains a group.
ActionView::Template::Error (Association named 'email_address' was not found on Group; perhaps you misspelled it?):
Causes:
ActiveRecord::AssociationNotFoundError (Association named 'email_address' was not found on Group; perhaps you misspelled it?)
11: <% if User.current.allowed_to?(:"view_#{watched_klass_name}_watchers", watched.project) %>
12: <h3><%= l(:"label_#{watched_klass_name}_watchers") %> (<%= watched.watcher_users.size %>)</h3>
13:
14: <%= watchers_list(watched) %>
15: <% else %>
16: <h3><%= l(:"label_#{watched_klass_name}_watchers") %></h3>
17: <% end %>
app/helpers/watchers_helper.rb:53:in 'Enumerable#collect'
app/helpers/watchers_helper.rb:53:in 'WatchersHelper#watchers_list'
app/views/watchers/_watchers.html.erb:14
app/views/issues/show.html.erb:147
app/views/issues/show.html.erb:141
app/controllers/issues_controller.rb:125:in 'block (2 levels) in IssuesController#show'
app/controllers/issues_controller.rb:112:in 'IssuesController#show'
lib/redmine/sudo_mode.rb:78:in 'Redmine::SudoMode::Controller#sudo_mode'
I have updated the patch to fix the error. The group now also has an 'email_address' association, which always returns nil.
- Target version changed from Candidate for next major release to 6.1.0
Setting the target version to 6.1.0.
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch in r23722.
Also available in: Atom
PDF