Module: JobStatus::Tracker

Defined in:
lib/job_status/tracker.rb

Overview

Tracking routines used by the callbacks

Class Method Summary collapse

Class Method Details

.enqueue(job_id) ⇒ Object

Sets the initial queued worker status and sets the expiry

Parameters:

  • job_id (String)

    ActiveJob ID to use as the key in storage



11
12
13
# File 'lib/job_status/tracker.rb', line 11

def self.enqueue(job_id)
  JobStatus.store.write(job_id, {status: :queued, at: 0, total: 100}, expires_in: 259200)
end

.remove(job_id) ⇒ Object

Removes any information from the cache for the given job_id

Parameters:

  • job_id (String)

    ActiveJob ID to use as the key in storage



31
32
33
# File 'lib/job_status/tracker.rb', line 31

def self.remove(job_id)
  JobStatus.store.delete(job_id)
end

.update(job_id, status) ⇒ Object

Stores the current status within the storage

Parameters:

  • job_id (String)

    ActiveJob ID to use as the key in storage



20
21
22
23
24
# File 'lib/job_status/tracker.rb', line 20

def self.update(job_id, status)
  cache = JobStatus.store.fetch(job_id)
  cache[:status] = status
  JobStatus.store.write(job_id, cache)
end