Commit e3bb6031 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '208892-remove-feature-flags-and-release-to-self-hosted-instances-step-5' into 'master'

Usage data usage_activity_by_stage feature flags

Closes #208892

See merge request gitlab-org/gitlab!26441
parents 456b6c66 078553cc
......@@ -37,21 +37,12 @@ module EE
override :uncached_data
def uncached_data
# The `usage_activity_by_stage` queries are likely to time out on large instances, and are sure
# to time out on GitLab.com. Since we are mostly interested in gathering these statistics for
# self hosted instances, prevent them from running on GitLab.com and allow instance maintainers
# to disable them via a feature flag.
return super if (::Feature.disabled?(:usage_ping_batch_counter) && ::Gitlab.com?) ||
::Feature.disabled?(:usage_activity_by_stage, default_enabled: true)
if ::Feature.disabled?(:usage_activity_by_stage_monthly)
super.merge(usage_activity_by_stage)
else
return super if ::Feature.disabled?(:usage_activity_by_stage, default_enabled: true)
time_period = { created_at: 28.days.ago..Time.current }
usage_activity_by_stage_monthly = usage_activity_by_stage(:usage_activity_by_stage_monthly, time_period)
super.merge(usage_activity_by_stage).merge(usage_activity_by_stage_monthly)
end
end
override :features_usage_data
def features_usage_data
......
......@@ -14,38 +14,6 @@ describe Gitlab::UsageData do
end
describe '.uncached_data' do
context 'when on Gitlab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it "does #{'not' unless usage_ping_batch_counter_on} include usage_activity_by_stage data" do
expect(described_class.uncached_data.include?(:usage_activity_by_stage)).to be(usage_ping_batch_counter_on)
expect(described_class.uncached_data.include?(:usage_activity_by_stage_monthly)).to be(usage_ping_batch_counter_on)
end
context 'when feature is enabled' do
before do
stub_feature_flags(usage_activity_by_stage: true)
end
it "does #{'not' unless usage_ping_batch_counter_on} include usage_activity_by_stage data" do
expect(described_class.uncached_data.include?(:usage_activity_by_stage)).to be(usage_ping_batch_counter_on)
expect(described_class.uncached_data.include?(:usage_activity_by_stage_monthly)).to be(usage_ping_batch_counter_on)
end
context 'when the :usage_activity_by_stage_monthly feature is disabled' do
before do
stub_feature_flags(usage_activity_by_stage_monthly: false)
end
it "does not include usage_activity_by_stage data" do
expect(described_class.uncached_data.include?(:usage_activity_by_stage_monthly)).to be(false)
end
end
end
end
context 'when the :usage_activity_by_stage feature is not enabled' do
before do
stub_feature_flags(usage_activity_by_stage: false)
......@@ -57,7 +25,7 @@ describe Gitlab::UsageData do
end
end
context 'when not on Gitlab.com' do
context 'when the :usage_activity_by_stage feature is enabled' do
it 'includes usage_activity_by_stage data' do
expect(described_class.uncached_data).to include(:usage_activity_by_stage)
expect(described_class.uncached_data).to include(:usage_activity_by_stage_monthly)
......
......@@ -232,7 +232,7 @@ module Gitlab
end
def count(relation, column = nil, fallback: -1, batch: true)
if batch && Feature.enabled?(:usage_ping_batch_counter)
if batch && Feature.enabled?(:usage_ping_batch_counter, default_enabled: true)
Gitlab::Database::BatchCount.batch_count(relation, column)
else
relation.count
......@@ -242,7 +242,7 @@ module Gitlab
end
def distinct_count(relation, column = nil, fallback: -1, batch: true)
if batch && Feature.enabled?(:usage_ping_batch_counter)
if batch && Feature.enabled?(:usage_ping_batch_counter, default_enabled: true)
Gitlab::Database::BatchCount.batch_distinct_count(relation, column)
else
relation.distinct_count_by(column)
......
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