diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-19 12:10:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-19 12:10:32 +0300 |
commit | fcef382cb994b8ecdbff75490bab0425a35f2641 (patch) | |
tree | 1789e9bbda6c4beea4451feb7970705296787445 /app/models/concerns/repositories | |
parent | b8f44765693d6f6e4c8df6ab7b7c7b1141f83b26 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/repositories')
-rw-r--r-- | app/models/concerns/repositories/can_housekeep_repository.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/concerns/repositories/can_housekeep_repository.rb b/app/models/concerns/repositories/can_housekeep_repository.rb new file mode 100644 index 00000000000..2b79851a07c --- /dev/null +++ b/app/models/concerns/repositories/can_housekeep_repository.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Repositories + module CanHousekeepRepository + extend ActiveSupport::Concern + + def pushes_since_gc + Gitlab::Redis::SharedState.with { |redis| redis.get(pushes_since_gc_redis_shared_state_key).to_i } + end + + def increment_pushes_since_gc + Gitlab::Redis::SharedState.with { |redis| redis.incr(pushes_since_gc_redis_shared_state_key) } + end + + def reset_pushes_since_gc + Gitlab::Redis::SharedState.with { |redis| redis.del(pushes_since_gc_redis_shared_state_key) } + end + + private + + def pushes_since_gc_redis_shared_state_key + "#{self.class.name.underscore.pluralize}/#{id}/pushes_since_gc" + end + end +end |