Commit 373b0b43 authored by Robert Speicher's avatar Robert Speicher

Merge branch '233994_inherit_web_ide_counter_from_base_counter' into 'master'

Inherit `WebIdeCounter` from `BaseCounter`

See merge request gitlab-org/gitlab!47405
parents 4f12e0d1 43f9edad
...@@ -2,54 +2,43 @@ ...@@ -2,54 +2,43 @@
module Gitlab module Gitlab
module UsageDataCounters module UsageDataCounters
class WebIdeCounter class WebIdeCounter < BaseCounter
extend RedisCounter KNOWN_EVENTS = %w[commits views merge_requests previews terminals pipelines].freeze
KNOWN_EVENTS = %i[commits views merge_requests previews terminals pipelines].freeze
PREFIX = 'web_ide' PREFIX = 'web_ide'
class << self class << self
def increment_commits_count def increment_commits_count
increment(redis_key('commits')) count('commits')
end end
def increment_merge_requests_count def increment_merge_requests_count
increment(redis_key('merge_requests')) count('merge_requests')
end end
def increment_views_count def increment_views_count
increment(redis_key('views')) count('views')
end end
def increment_terminals_count def increment_terminals_count
increment(redis_key('terminals')) count('terminals')
end end
def increment_pipelines_count def increment_pipelines_count
increment(redis_key('pipelines')) count('pipelines')
end end
def increment_previews_count def increment_previews_count
return unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? return unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?
increment(redis_key('previews')) count('previews')
end
def totals
KNOWN_EVENTS.map { |event| [counter_key(event), total_count(redis_key(event))] }.to_h
end
def fallback_totals
KNOWN_EVENTS.map { |event| [counter_key(event), -1] }.to_h
end end
private private
def redis_key(event) def redis_key(event)
"#{PREFIX}_#{event}_count".upcase require_known_event(event)
end
def counter_key(event) "#{prefix}_#{event}_count".upcase
"#{PREFIX}_#{event}".to_sym
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