Commit 3a3e135e authored by Stan Hu's avatar Stan Hu

Merge branch '247098-add-monthly-data-to-redis_hll_counters-in-usage-data' into 'master'

Add monthly data to redis_hll_counters in usage data

Closes #247098

See merge request gitlab-org/gitlab!41883
parents b6906b01 0cd40a9f
...@@ -72,7 +72,8 @@ module Gitlab ...@@ -72,7 +72,8 @@ module Gitlab
events_names = events_for_category(category) events_names = events_for_category(category)
event_results = events_names.each_with_object({}) do |event, hash| event_results = events_names.each_with_object({}) do |event, hash|
hash[event] = unique_events(event_names: event, start_date: 7.days.ago.to_date, end_date: Date.current) hash["#{event}_weekly"] = unique_events(event_names: event, start_date: 7.days.ago.to_date, end_date: Date.current)
hash["#{event}_monthly"] = unique_events(event_names: event, start_date: 4.weeks.ago.to_date, end_date: Date.current)
end end
if eligible_for_totals?(events_names) if eligible_for_totals?(events_names)
......
...@@ -238,16 +238,20 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s ...@@ -238,16 +238,20 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
it 'returns the number of unique events for all known events' do it 'returns the number of unique events for all known events' do
results = { results = {
'category1' => { "category1" => {
'event1_slot' => 1, "event1_slot_weekly" => 1,
'event2_slot' => 1, "event1_slot_monthly" => 1,
'category1_total_unique_counts_weekly' => 2, "event2_slot_weekly" => 1,
'category1_total_unique_counts_monthly' => 3 "event2_slot_monthly" => 2,
}, "category1_total_unique_counts_weekly" => 2,
'category2' => { "category1_total_unique_counts_monthly" => 3
'event3' => 1, },
'event4' => 1 "category2" => {
} "event3_weekly" => 1,
"event3_monthly" => 1,
"event4_weekly" => 1,
"event4_monthly" => 1
}
} }
expect(subject.unique_events_data).to eq(results) expect(subject.unique_events_data).to eq(results)
......
...@@ -1186,11 +1186,13 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1186,11 +1186,13 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
categories.each do |category| categories.each do |category|
keys = ::Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category(category) keys = ::Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category(category)
metrics = keys.map { |key| "#{key}_weekly" } + keys.map { |key| "#{key}_monthly" }
if ineligible_total_categories.exclude?(category) if ineligible_total_categories.exclude?(category)
keys.append("#{category}_total_unique_counts_weekly", "#{category}_total_unique_counts_monthly") metrics.append("#{category}_total_unique_counts_weekly", "#{category}_total_unique_counts_monthly")
end end
expect(subject[:redis_hll_counters][category].keys).to match_array(keys) expect(subject[:redis_hll_counters][category].keys).to match_array(metrics)
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