Sha256: fad58736e739f8e3f91d872a9fb88209d96664e87ba885fe588678124a01fca2

Contents?: true

Size: 647 Bytes

Versions: 4

Compression:

Stored size: 647 Bytes

Contents

module JobNotifier
  class Job < ActiveRecord::Base
    extend Enumerize

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

    enumerize :status, in: STATUSES, default: :pending

    def self.update_feedback(job_id, data, status)
      job = JobNotifier::Job.find_by(job_id: job_id)
      return unless job
      job.update_columns(result: data.to_s, status: status, notified: false)
    end

    def self.unnotified_by_identifier!(encoded_identifier)
      jobs = JobNotifier::Job.where(identifier: encoded_identifier).where(notified: false)
      job_ids = jobs.ids
      jobs.update_all(notified: true)
      where(id: job_ids)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
job_notifier-0.2.1 app/models/job_notifier/job.rb
job_notifier-0.2.0 app/models/job_notifier/job.rb
job_notifier-0.1.1 app/models/job_notifier/job.rb
job_notifier-0.1.0 app/models/job_notifier/job.rb