Commit 5dce1010 authored by Alper Akgun's avatar Alper Akgun Committed by Robert Speicher

Redis values for usage ping SQL dump rake task

Review comments
parent 1230f08e
---
title: Updated gitlab:usage_data:dump_sql_in_yaml rake task with redis usage
merge_request: 42189
author:
type: changed
......@@ -11,6 +11,14 @@ module Gitlab
raw_sql(relation, column, :distinct)
end
def redis_usage_data(counter = nil, &block)
if block_given?
{ redis_usage_data_block: block.to_s }
elsif counter.present?
{ redis_usage_data_counter: counter }
end
end
private
def raw_sql(relation, column, distinct = nil)
......
......@@ -18,4 +18,18 @@ RSpec.describe Gitlab::UsageDataQueries do
expect(described_class.distinct_count(Issue, :author_id)).to eq('SELECT COUNT(DISTINCT "issues"."author_id") FROM "issues"')
end
end
describe '.redis_usage_data' do
subject(:redis_usage_data) { described_class.redis_usage_data { 42 } }
it 'returns a class for redis_usage_data with a counter call' do
expect(described_class.redis_usage_data(Gitlab::UsageDataCounters::WikiPageCounter))
.to eq(redis_usage_data_counter: Gitlab::UsageDataCounters::WikiPageCounter)
end
it 'returns a stringified block for redis_usage_data with a block' do
is_expected.to include(:redis_usage_data_block)
expect(redis_usage_data[:redis_usage_data_block]).to start_with('#<Proc:')
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