diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2019-07-16 16:12:37 +0300 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-07-16 16:12:37 +0300 |
commit | 556d213cbc8b2ce44fd4d7fafde0a28804d3ae29 (patch) | |
tree | e5c6553cf1557b9f75166d4b99e71ec570acc626 /lib/gitlab/usage_data_counters | |
parent | f1b257f32ba8e9118b9e5ac84fd3c97d070551bb (diff) |
Refactored WebIdeCommitsCount class
We're adding more redis base counters to the web ide and other
classes. We're refactoring this class in other to use the logic
in other places.
Diffstat (limited to 'lib/gitlab/usage_data_counters')
-rw-r--r-- | lib/gitlab/usage_data_counters/redis_counter.rb | 19 | ||||
-rw-r--r-- | lib/gitlab/usage_data_counters/web_ide_commits_counter.rb | 13 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/gitlab/usage_data_counters/redis_counter.rb b/lib/gitlab/usage_data_counters/redis_counter.rb new file mode 100644 index 00000000000..123b8e1bef1 --- /dev/null +++ b/lib/gitlab/usage_data_counters/redis_counter.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Gitlab + module UsageDataCounters + module RedisCounter + def increment + Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) } + end + + def total_count + Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i } + end + + def redis_counter_key + raise NotImplementedError + end + end + end +end diff --git a/lib/gitlab/usage_data_counters/web_ide_commits_counter.rb b/lib/gitlab/usage_data_counters/web_ide_commits_counter.rb new file mode 100644 index 00000000000..62236fa07a3 --- /dev/null +++ b/lib/gitlab/usage_data_counters/web_ide_commits_counter.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module UsageDataCounters + class WebIdeCommitsCounter + extend RedisCounter + + def self.redis_counter_key + 'WEB_IDE_COMMITS_COUNT' + end + end + end +end |