Project

General

Profile

Actions

Feature #42589

closed

Optimize watchers list rendering by eager loading email addresses

Added by Go MAEDA about 1 month ago. Updated 24 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

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

Actions #1

Updated by Go MAEDA about 1 month ago

  • Target version changed from Candidate for next major release to 5.1.8

Setting the target version to 5.1.8.

Actions #2

Updated by Go MAEDA about 1 month ago

  • 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'
Actions #3

Updated by Go MAEDA 29 days ago

I have updated the patch to fix the error. The group now also has an 'email_address' association, which always returns nil.

Actions #4

Updated by Go MAEDA 29 days ago

  • Target version changed from Candidate for next major release to 6.1.0

Setting the target version to 6.1.0.

Actions #5

Updated by Go MAEDA 24 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r23722.

Actions

Also available in: Atom PDF