Class: Gitlab::BackgroundMigration::FixIncoherentPackagesSizeOnProjectStatistics::BufferedCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb

Constant Summary collapse

WORKER_DELAY =
10.minutes

Instance Method Summary collapse

Constructor Details

#initialize(stat) ⇒ BufferedCounter

Returns a new instance of BufferedCounter.



95
96
97
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 95

def initialize(stat)
  @stat = stat
end

Instance Method Details

#increment(amount) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 103

def increment(amount)
  Gitlab::Redis::SharedState.with do |redis|
    redis.incrby(key, amount)
  end

  FlushCounterIncrementsWorker.perform_in(
    WORKER_DELAY,
    'ProjectStatistics',
    @stat.id,
    :packages_size
  )
end

#keyObject



99
100
101
# File 'lib/gitlab/background_migration/fix_incoherent_packages_size_on_project_statistics.rb', line 99

def key
  "project:{#{@stat.project_id}}:counters:ProjectStatistics:#{@stat.id}:packages_size"
end