diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-03-28 12:03:38 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-03-28 12:03:38 +0300 |
commit | 8d07bc9c9f6846a2675c299953312a6ccfed4362 (patch) | |
tree | 80272c148310fef69a4afac15dee1ebfb95df8f3 /app/models | |
parent | 0540cb6b070579715c56942a7c92e4ba74920ebe (diff) | |
parent | c5f9b2be826c05e5f06d424f5c110976ad0b68c4 (diff) |
Merge branch 'fix-routes-n-plus-one-in-user-autocomplete' into 'master'
Remove N+1 queries from users autocomplete
See merge request gitlab-org/gitlab-ce!26491
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/members/group_member.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index 2c9e1ba1d80..510f856087d 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -14,6 +14,8 @@ class GroupMember < Member scope :in_groups, ->(groups) { where(source_id: groups.select(:id)) } + scope :count_users_by_group_id, -> { joins(:user).group(:source_id).count } + after_create :update_two_factor_requirement, unless: :invite? after_destroy :update_two_factor_requirement, unless: :invite? |