Project

General

Profile

Actions

Feature #42589

open

Optimize watchers list rendering by eager loading email addresses

Added by Go MAEDA 3 days ago. Updated about 20 hours ago.

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

0%

Estimated time:
Resolution:

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

optimize-watchers_list.patch (761 Bytes) optimize-watchers_list.patch Go MAEDA, 2025-04-16 09:22
Actions #1

Updated by Go MAEDA 2 days 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 20 hours 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

Also available in: Atom PDF