diff --git a/lib/qless/job.rb b/lib/qless/job.rb index 1214e8c2..32121bbd 100644 --- a/lib/qless/job.rb +++ b/lib/qless/job.rb @@ -43,7 +43,7 @@ class Job < BaseJob attr_reader :jid, :expires_at, :state, :queue_name, :worker_name, :failure attr_reader :klass_name, :tracked, :dependencies, :dependents attr_reader :original_retries, :retries_left, :raw_queue_history - attr_reader :state_changed + attr_reader :state_changed, :scheduleddate attr_accessor :data, :priority, :tags alias_method(:state_changed?, :state_changed) @@ -98,7 +98,8 @@ def self.build(client, klass, attributes = {}) 'failure' => {}, 'history' => [], 'dependencies' => [], - 'dependents' => [] + 'dependents' => [], + 'scheduleddate' => 0 } attributes = defaults.merge(Qless.stringify_hash_keys(attributes)) attributes['data'] = JSON.dump(attributes['data']) @@ -129,6 +130,7 @@ def initialize(client, atts) @original_retries = atts.fetch('retries') @retries_left = atts.fetch('remaining') @raw_queue_history = atts.fetch('history') + @scheduleddate = atts.fetch('scheduleddate') # This is a silly side-effect of Lua doing JSON parsing @tags = [] if @tags == {} @@ -143,6 +145,10 @@ def priority=(priority) @priority = priority if @client.call('priority', @jid, priority) end + def scheduledate + Time.at(@scheduleddate) + end + def [](key) @data[key] end