Class: RushJobMongoid::RushJob
- Inherits:
-
Object
- Object
- RushJobMongoid::RushJob
- Includes:
- Mongoid::Document
- Defined in:
- app/models/rush_job_mongoid/rush_job.rb
Class Method Summary collapse
- .clear_queue(queue_name, queue_priority) ⇒ Object
- .filter(filter_params) ⇒ Object
- .queue_groups ⇒ Object
Instance Method Summary collapse
Class Method Details
.clear_queue(queue_name, queue_priority) ⇒ Object
55 56 57 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 55 def self.clear_queue(queue_name, queue_priority) where(queue: queue_name, priority: queue_priority).delete_all end |
.filter(filter_params) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 59 def self.filter(filter_params) by_doc_id(filter_params[:doc_id]) .by_priority(filter_params[:priority]) .by_attempts(filter_params[:attempts]) .by_job_class(filter_params[:job_class]) .by_arguments(filter_params[:arguments]) .by_locked_by(filter_params[:locked_by]) .by_last_error(filter_params[:last_error]) .by_queue(filter_params[:queue]) end |
.queue_groups ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 41 def self.queue_groups groups = collection.aggregate([ { '$group' => { _id: { 'queue' => '$queue', 'priority' => '$priority' }, count: { '$sum' => 1 } } } ]).to_a group_result = groups.map do |group| { queue: group['_id']['queue'], priority: group['_id']['priority'], count: group['count'] } end group_result.sort_by! { |group| [group[:priority], group[:queue]] } end |
Instance Method Details
#error_message ⇒ Object
70 71 72 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 70 def errors..to_sentence end |
#job_arguments ⇒ Object
37 38 39 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 37 def job_arguments job_data&.fetch(:arguments).presence || '' end |
#job_class ⇒ Object
33 34 35 |
# File 'app/models/rush_job_mongoid/rush_job.rb', line 33 def job_class job_data&.fetch(:job_class) end |