Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-16 18:09:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-16 18:09:32 +0300
commit6de7d2c195a8a7fa5702cafa4365f7a9fcac37cd (patch)
treee976130993f87a9d1e1f19cdab0ebaf218dfff69 /app/models/project_team.rb
parent591b0e86e3dbaa31b68340a14dc32859306a27b1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/project_team.rb')
-rw-r--r--app/models/project_team.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index 072d281e5f8..5b7eded00cd 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -178,6 +178,40 @@ class ProjectTeam
max_member_access_for_user_ids([user_id])[user_id]
end
+ def contribution_check_for_user_ids(user_ids)
+ user_ids = user_ids.uniq
+ key = "contribution_check_for_users:#{project.id}"
+
+ Gitlab::SafeRequestStore[key] ||= {}
+ contributors = Gitlab::SafeRequestStore[key] || {}
+
+ user_ids -= contributors.keys
+
+ return contributors if user_ids.empty?
+
+ resource_contributors = project.merge_requests
+ .merged
+ .where(author_id: user_ids, target_branch: project.default_branch.to_s)
+ .pluck(:author_id)
+ .product([true]).to_h
+
+ contributors.merge!(resource_contributors)
+
+ missing_resource_ids = user_ids - resource_contributors.keys
+
+ missing_resource_ids.each do |resource_id|
+ contributors[resource_id] = false
+ end
+
+ contributors
+ end
+
+ def contributor?(user_id)
+ return false if max_member_access(user_id) >= Gitlab::Access::GUEST
+
+ contribution_check_for_user_ids([user_id])[user_id]
+ end
+
private
def fetch_members(level = nil)