Class: Counter::ReconciliationJob

Inherits:
Object
  • Object
show all
Defined in:
app/jobs/counter/reconciliation_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(counter_id) ⇒ Object

include Sidekiq::Worker



4
5
6
7
8
9
10
11
# File 'app/jobs/counter/reconciliation_job.rb', line 4

def perform counter_id
  counter = Counter::Value.find(counter_id)
  changes = Counter::Change.where(counter: counter).pending
  changes.with_lock do
    counter.increment! changes.sum(increment)
    changes.update_all processed: Time.now
  end
end