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

Merge branch 'ali/remove-promoted-issues-total-count' into 'master'

Remove total counts for snowplow events in usage ping

See merge request gitlab-org/gitlab!43768
parents 1a15fee1 0bc907db
...@@ -167,8 +167,7 @@ module Gitlab ...@@ -167,8 +167,7 @@ module Gitlab
user_preferences_usage, user_preferences_usage,
ingress_modsecurity_usage, ingress_modsecurity_usage,
container_expiration_policies_usage, container_expiration_policies_usage,
service_desk_counts, service_desk_counts
snowplow_event_counts
).tap do |data| ).tap do |data|
data[:snippets] = data[:personal_snippets] + data[:project_snippets] data[:snippets] = data[:personal_snippets] + data[:project_snippets]
end end
...@@ -176,7 +175,7 @@ module Gitlab ...@@ -176,7 +175,7 @@ module Gitlab
end end
# rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/AbcSize
def snowplow_event_counts(time_period: {}) def snowplow_event_counts(time_period)
return {} unless report_snowplow_events? return {} unless report_snowplow_events?
{ {
......
...@@ -1213,6 +1213,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1213,6 +1213,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end end
describe '.snowplow_event_counts' do describe '.snowplow_event_counts' do
let_it_be(:time_period) { { collector_tstamp: 8.days.ago..1.day.ago } }
context 'when self-monitoring project exists' do context 'when self-monitoring project exists' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
...@@ -1225,14 +1227,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1225,14 +1227,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
stub_feature_flags(product_analytics: project) stub_feature_flags(product_analytics: project)
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote') create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote')
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote', collector_tstamp: 28.days.ago) create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote', collector_tstamp: 2.days.ago)
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote', collector_tstamp: 9.days.ago)
create(:product_analytics_event, project: project, se_category: 'foo', se_action: 'bar', collector_tstamp: 2.days.ago)
end end
it 'returns promoted_issues for the time period' do it 'returns promoted_issues for the time period' do
expect(described_class.snowplow_event_counts[:promoted_issues]).to eq(2) expect(described_class.snowplow_event_counts(time_period)[:promoted_issues]).to eq(1)
expect(described_class.snowplow_event_counts(
time_period: described_class.last_28_days_time_period(column: :collector_tstamp)
)[:promoted_issues]).to eq(1)
end end
end end
...@@ -1242,14 +1244,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1242,14 +1244,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end end
it 'returns an empty hash' do it 'returns an empty hash' do
expect(described_class.snowplow_event_counts).to eq({}) expect(described_class.snowplow_event_counts(time_period)).to eq({})
end end
end end
end end
context 'when self-monitoring project does not exist' do context 'when self-monitoring project does not exist' do
it 'returns an empty hash' do it 'returns an empty hash' do
expect(described_class.snowplow_event_counts).to eq({}) expect(described_class.snowplow_event_counts(time_period)).to eq({})
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