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:
Diffstat (limited to 'app/services/admin/propagate_integration_service.rb')
-rw-r--r--app/services/admin/propagate_integration_service.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/services/admin/propagate_integration_service.rb b/app/services/admin/propagate_integration_service.rb
index 3c27454ffc7..34d6008cb6a 100644
--- a/app/services/admin/propagate_integration_service.rb
+++ b/app/services/admin/propagate_integration_service.rb
@@ -6,6 +6,8 @@ module Admin
def propagate
update_inherited_integrations
+
+ create_integration_for_groups_without_integration if Feature.enabled?(:group_level_integrations)
create_integration_for_projects_without_integration
end
@@ -38,9 +40,33 @@ module Admin
end
# rubocop: enable CodeReuse/ActiveRecord
+ def create_integration_for_groups_without_integration
+ loop do
+ batch = Group.uncached { group_ids_without_integration(integration, BATCH_SIZE) }
+
+ bulk_create_from_integration(batch, 'group') unless batch.empty?
+
+ break if batch.size < BATCH_SIZE
+ end
+ end
+
def service_hash
@service_hash ||= integration.to_service_hash
.tap { |json| json['inherit_from_id'] = integration.id }
end
+
+ # rubocop:disable CodeReuse/ActiveRecord
+ def group_ids_without_integration(integration, limit)
+ services = Service
+ .select('1')
+ .where('services.group_id = namespaces.id')
+ .where(type: integration.type)
+
+ Group
+ .where('NOT EXISTS (?)', services)
+ .limit(limit)
+ .pluck(:id)
+ end
+ # rubocop:enable CodeReuse/ActiveRecord
end
end