Commit de8d9965 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'clean-up-query_deploymenys_via_finished_at_in_vsa-ff' into 'master'

Remove VSA deployment query feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!54823
parents 528e71ae 6ef9a91d
---
name: query_deploymenys_via_finished_at_in_vsa
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53050
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/300649
milestone: '13.9'
type: development
group: group::optimize
default_enabled: true
...@@ -20,19 +20,13 @@ module Gitlab ...@@ -20,19 +20,13 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def deployments_count def deployments_count
@deployments_count ||= if Feature.enabled?(:query_deploymenys_via_finished_at_in_vsa, default_enabled: :yaml) @deployments_count ||= begin
deployments = DeploymentsFinder deployments = DeploymentsFinder
.new(group: group, finished_after: options[:from], finished_before: options[:to], status: :success) .new(group: group, finished_after: options[:from], finished_before: options[:to], status: :success)
.execute .execute
deployments = deployments.where(project_id: options[:projects]) if options[:projects].present? deployments = deployments.where(project_id: options[:projects]) if options[:projects].present?
deployments.count deployments.count
else
deployments = Deployment.joins(:project).merge(Project.inside_path(group.full_path))
deployments = deployments.where(projects: { id: options[:projects] }) if options[:projects].present?
deployments = deployments.where("deployments.created_at > ?", options[:from])
deployments = deployments.where("deployments.created_at < ?", options[:to]) if options[:to]
deployments.success.count
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -127,7 +127,6 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d ...@@ -127,7 +127,6 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d
end end
end end
shared_examples 'shared examples for #deploys' do
describe "#deploys" do describe "#deploys" do
context 'with from date' do context 'with from date' do
before do before do
...@@ -193,7 +192,6 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d ...@@ -193,7 +192,6 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d
expect(subject.second[:value]).to eq('-') expect(subject.second[:value]).to eq('-')
end end
end end
end
describe '#deployment_frequency' do describe '#deployment_frequency' do
let(:from) { 6.days.ago } let(:from) { 6.days.ago }
...@@ -241,20 +239,4 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d ...@@ -241,20 +239,4 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d
end end
end end
end end
context 'when query_deploymenys_via_finished_at_in_vsa feature flag is enabled' do
before do
stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: true)
end
it_behaves_like 'shared examples for #deploys'
end
context 'when query_deploymenys_via_finished_at_in_vsa feature flag is disabled' do
before do
stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: false)
end
it_behaves_like 'shared examples for #deploys'
end
end end
...@@ -15,16 +15,10 @@ module Gitlab ...@@ -15,16 +15,10 @@ module Gitlab
private private
def deployments_count def deployments_count
if Feature.enabled?(:query_deploymenys_via_finished_at_in_vsa, default_enabled: :yaml)
DeploymentsFinder DeploymentsFinder
.new(project: @project, finished_after: @from, finished_before: @to, status: :success) .new(project: @project, finished_after: @from, finished_before: @to, status: :success)
.execute .execute
.count .count
else
query = @project.deployments.success.where("created_at >= ?", @from)
query = query.where("created_at <= ?", @to) if @to
query.count
end
end end
end end
end end
......
...@@ -230,26 +230,6 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do ...@@ -230,26 +230,6 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do
end end
context 'when `from` and `to` are within a day' do context 'when `from` and `to` are within a day' do
context 'when query_deploymenys_via_finished_at_in_vsa feature flag is off' do
before do
stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: false)
end
it 'returns the number of deployments made on that day' do
freeze_time do
create(:deployment, :success, project: project)
options[:from] = options[:to] = Time.zone.now
expect(subject).to eq('1')
end
end
end
context 'when query_deploymenys_via_finished_at_in_vsa feature flag is off' do
before do
stub_feature_flags(query_deploymenys_via_finished_at_in_vsa: true)
end
it 'returns the number of deployments made on that day' do it 'returns the number of deployments made on that day' do
freeze_time do freeze_time do
create(:deployment, :success, project: project, finished_at: Time.zone.now) create(:deployment, :success, project: project, finished_at: Time.zone.now)
...@@ -262,5 +242,4 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do ...@@ -262,5 +242,4 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do
end end
end end
end end
end
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