Sha256: be92735a28a9078b929c576da7937e4ea4c811d9d856ac084f24280c86995f71

Contents?: true

Size: 692 Bytes

Versions: 9

Compression:

Stored size: 692 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)
      JobNotifier::Job.where(identifier: encoded_identifier).where(notified: false)
    end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
job_notifier-1.3.0 app/models/job_notifier/job.rb
job_notifier-1.2.4 app/models/job_notifier/job.rb
job_notifier-1.2.3 app/models/job_notifier/job.rb
job_notifier-1.2.2 app/models/job_notifier/job.rb
job_notifier-1.2.1 app/models/job_notifier/job.rb
job_notifier-1.2.0 app/models/job_notifier/job.rb
job_notifier-1.1.1 app/models/job_notifier/job.rb
job_notifier-1.1.0 app/models/job_notifier/job.rb
job_notifier-1.0.0 app/models/job_notifier/job.rb