From 42e0eda49c8b1371436acb2f6ad839ef4084bcf8 Mon Sep 17 00:00:00 2001 From: Stephen Russett Date: Sat, 17 May 2014 16:52:39 -0400 Subject: [PATCH 1/4] Added scheduled date to attr_reader --- lib/qless/job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/qless/job.rb b/lib/qless/job.rb index 1214e8c2..92583c22 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) From 5c0c6780003779dac0ed4b913ea0a4e1135d6047 Mon Sep 17 00:00:00 2001 From: Stephen Russett Date: Sat, 17 May 2014 16:52:50 -0400 Subject: [PATCH 2/4] Added default value for scheduled date --- lib/qless/job.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/qless/job.rb b/lib/qless/job.rb index 92583c22..5d213930 100644 --- a/lib/qless/job.rb +++ b/lib/qless/job.rb @@ -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']) From be528a76c51beab2a4fb3f2012566e8ba6d8c74a Mon Sep 17 00:00:00 2001 From: Stephen Russett Date: Sat, 17 May 2014 16:53:02 -0400 Subject: [PATCH 3/4] add var for scheduled date --- lib/qless/job.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/qless/job.rb b/lib/qless/job.rb index 5d213930..efcd2a3a 100644 --- a/lib/qless/job.rb +++ b/lib/qless/job.rb @@ -130,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 == {} From 5de196c19893bf5d88f6ab93498d384b7d8a4ef2 Mon Sep 17 00:00:00 2001 From: Stephen Russett Date: Sat, 17 May 2014 16:54:22 -0400 Subject: [PATCH 4/4] method for returning scheduled date as a Time obj --- lib/qless/job.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/qless/job.rb b/lib/qless/job.rb index efcd2a3a..32121bbd 100644 --- a/lib/qless/job.rb +++ b/lib/qless/job.rb @@ -145,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