Commit b92364cc authored by Erick Bajao's avatar Erick Bajao

Remove query_project_ci_feature_usages_for_coverage flag

This removes the feature flag and completely enables
querying from the new CI feature usages table to determine
which projects have coverages.

Changelog: changed
EE: true
parent 2a8d26b3
---
name: query_project_ci_feature_usages_for_coverage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69890
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339974
milestone: '14.3'
type: development
group: group::testing
default_enabled: false
...@@ -39,11 +39,7 @@ module EE ...@@ -39,11 +39,7 @@ module EE
def with_code_coverage(items) def with_code_coverage(items)
return items unless params[:has_code_coverage].present? return items unless params[:has_code_coverage].present?
if ::Feature.enabled?(:query_project_ci_feature_usages_for_coverage, namespace, default_enabled: :yaml)
items.with_coverage_feature_usage(default_branch: true) items.with_coverage_feature_usage(default_branch: true)
else
items.with_code_coverage
end
end end
end end
end end
......
...@@ -122,11 +122,6 @@ module EE ...@@ -122,11 +122,6 @@ module EE
.limit(limit) .limit(limit)
end end
scope :with_code_coverage, -> do
joins(:daily_build_group_report_results).merge(::Ci::DailyBuildGroupReportResult.with_coverage.with_default_branch).group(:id)
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/339974')
end
scope :with_coverage_feature_usage, ->(default_branch: nil) do scope :with_coverage_feature_usage, ->(default_branch: nil) do
join_conditions = { feature: :code_coverage } join_conditions = { feature: :code_coverage }
join_conditions[:default_branch] = default_branch unless default_branch.nil? join_conditions[:default_branch] = default_branch unless default_branch.nil?
......
...@@ -69,11 +69,6 @@ RSpec.describe Namespaces::ProjectsFinder do ...@@ -69,11 +69,6 @@ RSpec.describe Namespaces::ProjectsFinder do
create(:ci_daily_build_group_report_result, project: project_2, default_branch: false) create(:ci_daily_build_group_report_result, project: project_2, default_branch: false)
end end
context 'and query_project_ci_feature_usages_for_coverage flag is enabled for the given group' do
before do
stub_feature_flags(query_project_ci_feature_usages_for_coverage: namespace)
end
it 'returns projects with code coverage on default branch based on ci feature usages' do it 'returns projects with code coverage on default branch based on ci feature usages' do
record = ActiveRecord::QueryRecorder.new do record = ActiveRecord::QueryRecorder.new do
expect(projects).to contain_exactly(project_1) expect(projects).to contain_exactly(project_1)
...@@ -85,23 +80,6 @@ RSpec.describe Namespaces::ProjectsFinder do ...@@ -85,23 +80,6 @@ RSpec.describe Namespaces::ProjectsFinder do
end end
end end
context 'and query_project_ci_feature_usages_for_coverage flag is disabled for the given group' do
before do
stub_feature_flags(query_project_ci_feature_usages_for_coverage: create(:group))
end
it 'returns projects with code coverage on default branch based on daily build group report results' do
record = ActiveRecord::QueryRecorder.new do
expect(projects).to contain_exactly(project_1)
end
queried_ci_table = record.log.any? {|l| l.include?('ci_daily_build_group_report_results')}
expect(queried_ci_table).to eq(true)
end
end
end
context 'when has_code_coverage is not provided' do context 'when has_code_coverage is not provided' do
it 'returns all projects' do it 'returns all projects' do
expect(projects).to contain_exactly(project_1, project_2) expect(projects).to contain_exactly(project_1, project_2)
......
...@@ -78,11 +78,6 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do ...@@ -78,11 +78,6 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
create(:ci_daily_build_group_report_result, project: project_2, default_branch: false) create(:ci_daily_build_group_report_result, project: project_2, default_branch: false)
end end
context 'and query_project_ci_feature_usages_for_coverage flag is enabled for the given group' do
before do
stub_feature_flags(query_project_ci_feature_usages_for_coverage: group)
end
it 'returns projects with code coverage on default branch based on ci feature usages' do it 'returns projects with code coverage on default branch based on ci feature usages' do
record = ActiveRecord::QueryRecorder.new do record = ActiveRecord::QueryRecorder.new do
expect(projects).to contain_exactly(project_1) expect(projects).to contain_exactly(project_1)
...@@ -93,23 +88,6 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do ...@@ -93,23 +88,6 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
expect(queried_ci_table).to eq(false) expect(queried_ci_table).to eq(false)
end end
end end
context 'and query_project_ci_feature_usages_for_coverage flag is disabled for the given group' do
before do
stub_feature_flags(query_project_ci_feature_usages_for_coverage: false)
end
it 'returns projects with code coverage on default branch based on daily build group report results' do
record = ActiveRecord::QueryRecorder.new do
expect(projects).to contain_exactly(project_1)
end
queried_ci_table = record.log.any? {|l| l.include?('ci_daily_build_group_report_results')}
expect(queried_ci_table).to eq(true)
end
end
end
end end
end end
end end
......
...@@ -414,19 +414,6 @@ RSpec.describe Project do ...@@ -414,19 +414,6 @@ RSpec.describe Project do
it { is_expected.to eq([project_2, project_3, project_1]) } it { is_expected.to eq([project_2, project_3, project_1]) }
end end
describe '.with_code_coverage' do
let_it_be(:project_1) { create(:project) }
let_it_be(:project_2) { create(:project) }
let_it_be(:project_3) { create(:project) }
let!(:coverage_1) { create(:ci_daily_build_group_report_result, project: project_1) }
let!(:coverage_2) { create(:ci_daily_build_group_report_result, project: project_2) }
subject { described_class.with_code_coverage }
it { is_expected.to contain_exactly(project_1, project_2) }
end
describe '.with_coverage_feature_usage' do describe '.with_coverage_feature_usage' do
let_it_be(:project_1) { create(:project) } let_it_be(:project_1) { create(:project) }
let_it_be(:project_2) { create(:project) } let_it_be(:project_2) { create(:project) }
......
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