From 3832718d895bf8268f3e3aac85948e2792769345 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 22 Jan 2020 18:08:47 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index e86c0a1826d..bc113c72762 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -101,6 +101,7 @@ class User < ApplicationRecord # Groups has_many :members + has_one :max_access_level_membership, -> { select(:id, :user_id, :access_level).order(access_level: :desc).readonly }, class_name: 'Member' has_many :group_members, -> { where(requested_at: nil) }, source: 'GroupMember' has_many :groups, through: :group_members has_many :owned_groups, -> { where(members: { access_level: Gitlab::Access::OWNER }) }, through: :group_members, source: :group @@ -1027,7 +1028,7 @@ class User < ApplicationRecord end def highest_role - members.maximum(:access_level) || Gitlab::Access::NO_ACCESS + max_access_level_membership&.access_level || Gitlab::Access::NO_ACCESS end def accessible_deploy_keys -- cgit v1.2.1