Class: JobNotifier::Job

Inherits:
ApplicationRecord
  • Object
show all
Extended by:
Enumerize
Defined in:
app/models/job_notifier/job.rb

Constant Summary collapse

STATUSES =
[:pending, :finished, :failed]

Class Method Summary collapse

Class Method Details

.notify_by_identifier(encoded_identifier) ⇒ Object



20
21
22
# File 'app/models/job_notifier/job.rb', line 20

def self.notify_by_identifier(encoded_identifier)
  unnotified_by_identifier(encoded_identifier).update_all(notified: true)
end

.unnotified_by_identifier(encoded_identifier) ⇒ Object



16
17
18
# File 'app/models/job_notifier/job.rb', line 16

def self.unnotified_by_identifier(encoded_identifier)
  JobNotifier::Job.where(identifier: encoded_identifier).where(notified: false)
end

.update_feedback(job_id, data, status) ⇒ Object



9
10
11
12
13
14
# File 'app/models/job_notifier/job.rb', line 9

def self.update_feedback(job_id, data, status)
  job = JobNotifier::Job.find_by(job_id: job_id)
  return unless job

  job.update(result: data.to_s, status: status, notified: false)
end