Module: RocketJob::Batch::Statistics

Extended by:
ActiveSupport::Concern
Included in:
Jobs::OnDemandBatchJob
Defined in:
lib/rocket_job/batch/statistics.rb

Overview

Allow statistics to be gathered while a batch job is running

Defined Under Namespace

Classes: Stats

Instance Method Summary collapse

Instance Method Details

#statistics_inc(key, increment = 1) ⇒ Object

Increment a statistic



60
61
62
63
64
65
66
# File 'lib/rocket_job/batch/statistics.rb', line 60

def statistics_inc(key, increment = 1)
  return if key.nil? || key == ""

  # Being called within tests outside of a perform
  @slice_statistics ||= Stats.new(new_record? ? statistics : nil)
  key.is_a?(Hash) ? @slice_statistics.inc(key) : @slice_statistics.inc_key(key, increment)
end