Class: Que::ActiveRecord::Model

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/que/active_record/model.rb

Class Method Summary collapse

Class Method Details

.by_args(*args, **kwargs) ⇒ Object



43
44
45
# File 'lib/que/active_record/model.rb', line 43

def by_args(*args, **kwargs)
  where("que_jobs.args @> ? AND que_jobs.kwargs @> ?", JSON.dump(args), JSON.dump(kwargs))
end

.by_job_class(job_class) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/que/active_record/model.rb', line 26

def by_job_class(job_class)
  job_class = job_class.name if job_class.is_a?(Class)
  job_class_doc = "[{\"job_class\": \"#{job_class}\"}]"
  where(
    "que_jobs.job_class = ? OR (que_jobs.job_class = 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' AND que_jobs.args @> ?)",
    job_class, job_class_doc,
  )
end

.by_queue(queue) ⇒ Object



35
36
37
# File 'lib/que/active_record/model.rb', line 35

def by_queue(queue)
  where(arel_table[:queue].eq(queue))
end

.by_tag(tag) ⇒ Object



39
40
41
# File 'lib/que/active_record/model.rb', line 39

def by_tag(tag)
  where("que_jobs.data @> ?", JSON.dump(tags: [tag]))
end