Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d2c01d8a
Commit
d2c01d8a
authored
Mar 15, 2022
by
Doug Stull
Committed by
Matthias Käppler
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use SafeRequestLoader to dry up logic in contribution check
parent
2b592225
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
24 deletions
+8
-24
app/models/project_team.rb
app/models/project_team.rb
+8
-24
No files found.
app/models/project_team.rb
View file @
d2c01d8a
...
...
@@ -198,31 +198,15 @@ class ProjectTeam
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
Gitlab
::
SafeRequestLoader
.
execute
(
resource_key:
"contribution_check_for_users:
#{
project
.
id
}
"
,
resource_ids:
user_ids
,
default_value:
false
)
do
|
user_ids
|
project
.
merge_requests
.
merged
.
where
(
author_id:
user_ids
,
target_branch:
project
.
default_branch
.
to_s
)
.
pluck
(
:author_id
)
.
product
([
true
]).
to_h
end
contributors
end
def
contributor?
(
user_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment