gitlab-org--gitlab-foss/lib/gitlab/web_ide_commits_counter.rb
Tiago Botelho 1e662293e8 Implements Web IDE commits counter in Redis
This makes a temporary implementation of the
Web IDE commits counter using Redis while
https://gitlab.com/gitlab-org/gitlab-ce/issues/52096
is being discussed further for a more generic
approach to counters
2018-10-03 11:34:48 +01:00

17 lines
404 B
Ruby

# frozen_string_literal: true
module Gitlab
module WebIdeCommitsCounter
WEB_IDE_COMMITS_KEY = "WEB_IDE_COMMITS_COUNT".freeze
class << self
def increment
Gitlab::Redis::SharedState.with { |redis| redis.incr(WEB_IDE_COMMITS_KEY) }
end
def total_count
Gitlab::Redis::SharedState.with { |redis| redis.get(WEB_IDE_COMMITS_KEY).to_i }
end
end
end
end