summaryrefslogtreecommitdiff
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-09-05 11:03:24 -0500
committerRubén Dávila <ruben@gitlab.com>2017-09-05 15:54:07 -0500
commit66cfb901c0df6eb5741721e901b66fbe82e183ce (patch)
tree89010ac7169b33eaae719fca19cc695eb7999a9d /app/models/group.rb
parentb8b4993805c620f6c29f3189b6e151c47854c5b7 (diff)
downloadgitlab-ce-66cfb901c0df6eb5741721e901b66fbe82e183ce.tar.gz
Optimize SQL queries used in Groups::GroupMembersController#create27374-groups-groupmemberscontroller-create-is-slow-due-to-sql
The following optimizations were performed: - Add new association to GroupMember and ProjectMember This new association will allow us to check if a user is a member of a Project or Group through a single query instead of two. - Optimize retrieving of Members when adding multiple Users
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 190b27cf66b..e746e4a12c9 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -16,6 +16,7 @@ class Group < Namespace
source: :user
has_many :requesters, -> { where.not(requested_at: nil) }, dependent: :destroy, as: :source, class_name: 'GroupMember' # rubocop:disable Cop/ActiveRecordDependent
+ has_many :members_and_requesters, as: :source, class_name: 'GroupMember'
has_many :milestones
has_many :project_group_links, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent