debian-mirror-gitlab/lib/gitlab/usage_data_counters/web_ide_counter.rb

60 lines
1.4 KiB
Ruby
Raw Normal View History

2019-09-30 21:07:59 +05:30
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class WebIdeCounter
extend RedisCounter
COMMITS_COUNT_KEY = 'WEB_IDE_COMMITS_COUNT'
2019-10-12 21:52:04 +05:30
MERGE_REQUEST_COUNT_KEY = 'WEB_IDE_MERGE_REQUESTS_COUNT'
VIEWS_COUNT_KEY = 'WEB_IDE_VIEWS_COUNT'
2019-12-26 22:10:19 +05:30
PREVIEW_COUNT_KEY = 'WEB_IDE_PREVIEWS_COUNT'
2019-09-30 21:07:59 +05:30
class << self
def increment_commits_count
increment(COMMITS_COUNT_KEY)
end
def total_commits_count
total_count(COMMITS_COUNT_KEY)
end
2019-10-12 21:52:04 +05:30
def increment_merge_requests_count
increment(MERGE_REQUEST_COUNT_KEY)
end
def total_merge_requests_count
total_count(MERGE_REQUEST_COUNT_KEY)
end
def increment_views_count
increment(VIEWS_COUNT_KEY)
end
def total_views_count
total_count(VIEWS_COUNT_KEY)
end
2019-12-26 22:10:19 +05:30
def increment_previews_count
return unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?
increment(PREVIEW_COUNT_KEY)
end
def total_previews_count
total_count(PREVIEW_COUNT_KEY)
end
2019-10-12 21:52:04 +05:30
def totals
{
web_ide_commits: total_commits_count,
web_ide_views: total_views_count,
2019-12-26 22:10:19 +05:30
web_ide_merge_requests: total_merge_requests_count,
web_ide_previews: total_previews_count
2019-10-12 21:52:04 +05:30
}
end
2019-09-30 21:07:59 +05:30
end
end
end
end