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
events_names = events_for_category(category)
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
if eligible_for_totals?(events_names)
......
......@@ -238,15 +238,19 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
it 'returns the number of unique events for all known events' do
results = {
'category1' => {
'event1_slot' => 1,
'event2_slot' => 1,
'category1_total_unique_counts_weekly' => 2,
'category1_total_unique_counts_monthly' => 3
"category1" => {
"event1_slot_weekly" => 1,
"event1_slot_monthly" => 1,
"event2_slot_weekly" => 1,
"event2_slot_monthly" => 2,
"category1_total_unique_counts_weekly" => 2,
"category1_total_unique_counts_monthly" => 3
},
'category2' => {
'event3' => 1,
'event4' => 1
"category2" => {
"event3_weekly" => 1,
"event3_monthly" => 1,
"event4_weekly" => 1,
"event4_monthly" => 1
}
}
......
......@@ -1186,11 +1186,13 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
categories.each do |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)
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
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
......
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