summaryrefslogtreecommitdiff
path: root/app/models/event.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-02-13 15:19:03 +0100
committerRémy Coutable <remy@rymai.me>2017-02-13 15:23:23 +0100
commit1698d71ccfce229b8d7c36a87a67764d53e97c8b (patch)
tree9777e8d20930e524c361acae36fe8811d8e5257e /app/models/event.rb
parent473b04a9f07ded15538af23f986ec618f5f8160c (diff)
downloadgitlab-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.rb2
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