diff options
author | Rémy Coutable <remy@rymai.me> | 2017-02-13 15:19:03 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-02-13 15:23:23 +0100 |
commit | 1698d71ccfce229b8d7c36a87a67764d53e97c8b (patch) | |
tree | 9777e8d20930e524c361acae36fe8811d8e5257e /app/models/event.rb | |
parent | 473b04a9f07ded15538af23f986ec618f5f8160c (diff) | |
download | gitlab-ce-1698d71ccfce229b8d7c36a87a67764d53e97c8b.tar.gz |
Use preload for Event#target since it's a polymorphic association27395-reduce-group-activity-sql-queries
Also, don't use limit in subquery, MySQL don't like that.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/event.rb')
-rw-r--r-- | app/models/event.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 57f441187b4..cf89ac5207f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -39,7 +39,7 @@ class Event < ActiveRecord::Base where(project_id: projects).recent end - scope :with_associations, -> { includes(:author, :project, :target, project: :namespace) } + scope :with_associations, -> { includes(:author, :project, project: :namespace).preload(:target) } scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) } class << self |