diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-11-14 06:07:35 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-12-10 21:34:33 +0100 |
commit | 4f5abe43279e96efde5f8cac66cbff30d8a95f28 (patch) | |
tree | 931664a9662da2de4ce46781d2715f6426afc120 /app/models | |
parent | 1297a1bd7dcccaa4e233925c8467c2bbe41a4bf2 (diff) | |
download | gitlab-ce-4f5abe43279e96efde5f8cac66cbff30d8a95f28.tar.gz |
Reduce N+1 from Activity Dashboard and Banzai
There is a combination of few strategies implemented here:
1. Few relations were eager loaded
2. Changed few polymorphic routes to specific ones so we don't have to
use `#becomes(Namespace)` which doesn't preserve association cache
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/event.rb | 2 | ||||
-rw-r--r-- | app/models/note.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 2e690f8c013..2ceef412af5 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -87,7 +87,7 @@ class Event < ActiveRecord::Base scope :with_associations, -> do # We're using preload for "push_event_payload" as otherwise the association # is not always available (depending on the query being built). - includes(:author, :project, project: :namespace) + includes(:author, :project, project: [:project_feature, :import_data, :namespace]) .preload(:target, :push_event_payload) end diff --git a/app/models/note.rb b/app/models/note.rb index a6ae4f58ac4..17c7d97fa0a 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -131,7 +131,7 @@ class Note < ActiveRecord::Base scope :with_associations, -> do # FYI noteable cannot be loaded for LegacyDiffNote for commits includes(:author, :noteable, :updated_by, - project: [:project_members, { group: [:group_members] }]) + project: [:project_members, :namespace, { group: [:group_members] }]) end scope :with_metadata, -> { includes(:system_note_metadata) } |