Commit 88904127 authored by Arturo Herrero's avatar Arturo Herrero

Improve method name

Rename inherited_descendant_integrations_for to
inherited_descendants_from_self_or_ancestors_from.
parent 0de0357a
......@@ -274,7 +274,7 @@ class Service < ApplicationRecord
end
end
def self.inherited_descendant_integrations_for(integration)
def self.inherited_descendants_from_self_or_ancestors_from(integration)
inherit_from_ids =
where(type: integration.type, group: integration.group.self_and_ancestors)
.or(where(type: integration.type, instance: true)).select(:id)
......
......@@ -27,7 +27,7 @@ module Admin
end
def update_inherited_descendant_integrations
Service.inherited_descendant_integrations_for(integration).in_batches(of: BATCH_SIZE) do |services|
Service.inherited_descendants_from_self_or_ancestors_from(integration).in_batches(of: BATCH_SIZE) do |services|
min_id, max_id = services.pick("MIN(services.id), MAX(services.id)")
PropagateIntegrationInheritDescendantWorker.perform_async(integration.id, min_id, max_id)
end
......
......@@ -11,7 +11,7 @@ class PropagateIntegrationInheritDescendantWorker
integration = Service.find_by_id(integration_id)
return unless integration
batch = Service.inherited_descendant_integrations_for(integration).where(id: min_id..max_id)
batch = Service.inherited_descendants_from_self_or_ancestors_from(integration).where(id: min_id..max_id)
BulkUpdateIntegrationService.new(integration, batch).execute
end
......
......@@ -599,7 +599,7 @@ RSpec.describe Service do
end
end
describe '.inherited_descendant_integrations_for' do
describe '.inherited_descendants_from_self_or_ancestors_from' do
let(:subgroup1) { create(:group, parent: group) }
let(:subgroup2) { create(:group, parent: group) }
let(:project1) { create(:project, group: subgroup1) }
......@@ -611,8 +611,8 @@ RSpec.describe Service do
let!(:project_integration2) { create(:prometheus_service, group: nil, project: project2, inherit_from_id: subgroup_integration2.id) }
it 'returns the groups and projects inheriting from integration ancestors', :aggregate_failures do
expect(described_class.inherited_descendant_integrations_for(group_integration)).to eq([subgroup_integration1, project_integration1])
expect(described_class.inherited_descendant_integrations_for(subgroup_integration2)).to eq([project_integration2])
expect(described_class.inherited_descendants_from_self_or_ancestors_from(group_integration)).to eq([subgroup_integration1, project_integration1])
expect(described_class.inherited_descendants_from_self_or_ancestors_from(subgroup_integration2)).to eq([project_integration2])
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment