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>2022-05-10 21:08:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-10 21:08:27 +0300
commit56b3925584320c4406b7cb961fbe19ff9f9c41d4 (patch)
treeea7fdd802d958c585ecf46045ccf1db52417b096 /app/finders
parent758b97662c5a6af41357cec7e25fc8cddadd8b9c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/groups/projects_requiring_authorizations_refresh/base.rb35
-rw-r--r--app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb28
-rw-r--r--app/finders/groups/projects_requiring_authorizations_refresh/on_transfer_finder.rb17
3 files changed, 53 insertions, 27 deletions
diff --git a/app/finders/groups/projects_requiring_authorizations_refresh/base.rb b/app/finders/groups/projects_requiring_authorizations_refresh/base.rb
new file mode 100644
index 00000000000..c719e6ba903
--- /dev/null
+++ b/app/finders/groups/projects_requiring_authorizations_refresh/base.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+module Groups
+ module ProjectsRequiringAuthorizationsRefresh
+ class Base
+ def initialize(group)
+ @group = group
+ end
+
+ private
+
+ def ids_of_projects_in_hierarchy_and_project_shares(group)
+ project_ids = Set.new
+
+ ids_of_projects_in_hierarchy = group.all_projects.pluck(:id) # rubocop: disable CodeReuse/ActiveRecord
+ ids_of_projects_in_project_shares = ids_of_projects_shared_with_self_and_descendant_groups(group)
+
+ project_ids.merge(ids_of_projects_in_hierarchy)
+ project_ids.merge(ids_of_projects_in_project_shares)
+
+ project_ids
+ end
+
+ def ids_of_projects_shared_with_self_and_descendant_groups(group, batch_size: 50)
+ project_ids = Set.new
+
+ group.self_and_descendants_ids.each_slice(batch_size) do |group_ids|
+ project_ids.merge(ProjectGroupLink.in_group(group_ids).pluck(:project_id)) # rubocop: disable CodeReuse/ActiveRecord
+ end
+
+ project_ids
+ end
+ end
+ end
+end
diff --git a/app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb b/app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb
index 909a896d77c..f6b8b999b99 100644
--- a/app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb
+++ b/app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb
@@ -8,11 +8,7 @@
module Groups
module ProjectsRequiringAuthorizationsRefresh
- class OnDirectMembershipFinder
- def initialize(group)
- @group = group
- end
-
+ class OnDirectMembershipFinder < Base
def execute
project_ids = Set.new
@@ -24,28 +20,6 @@ module Groups
private
- def ids_of_projects_in_hierarchy_and_project_shares(group)
- project_ids = Set.new
-
- ids_of_projects_in_hierarchy = group.all_projects.pluck(:id) # rubocop: disable CodeReuse/ActiveRecord
- ids_of_projects_in_project_shares = ids_of_projects_shared_with_self_and_descendant_groups(group)
-
- project_ids.merge(ids_of_projects_in_hierarchy)
- project_ids.merge(ids_of_projects_in_project_shares)
-
- project_ids
- end
-
- def ids_of_projects_shared_with_self_and_descendant_groups(group, batch_size: 50)
- project_ids = Set.new
-
- group.self_and_descendants_ids.each_slice(batch_size) do |group_ids|
- project_ids.merge(ProjectGroupLink.in_group(group_ids).pluck(:project_id)) # rubocop: disable CodeReuse/ActiveRecord
- end
-
- project_ids
- end
-
def ids_of_projects_in_hierarchy_and_project_shares_of_shared_groups(group, batch_size: 10)
project_ids = Set.new
diff --git a/app/finders/groups/projects_requiring_authorizations_refresh/on_transfer_finder.rb b/app/finders/groups/projects_requiring_authorizations_refresh/on_transfer_finder.rb
new file mode 100644
index 00000000000..781e1222287
--- /dev/null
+++ b/app/finders/groups/projects_requiring_authorizations_refresh/on_transfer_finder.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# Groups::ProjectsRequiringAuthorizationsRefresh::OnTransferFinder
+#
+# Given a group, this finder can be used to obtain a list of Project IDs of projects
+# that requires their `project_authorizations` records to be refreshed in the event where
+# the group has been transferred.
+
+module Groups
+ module ProjectsRequiringAuthorizationsRefresh
+ class OnTransferFinder < Base
+ def execute
+ ids_of_projects_in_hierarchy_and_project_shares(@group).to_a
+ end
+ end
+ end
+end