rocketjob 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_job/job.rb +13 -6
- data/lib/rocket_job/version.rb +1 -1
- data/test/job_worker_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2d5bd2e258623a70cb2ac81bb559db1302d2c40
|
4
|
+
data.tar.gz: 5e478b33ac8e404496ca112536dcd57e24d3b369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c39b919588cd3f58490294e92ef2233f397a867b4e3bf41073e16374238348f6a2ec892a2dfbcc73ed838ef62c3344a6a3d7ec9289e70ba4ee575cf5ab096a7
|
7
|
+
data.tar.gz: 07603275a4346907ea05613012582cbf746571011d25bb4bb42d3bfa022932c8867030025a338e83aa21f8de9eb597e9cee83d9cb34e3eb9175054da8c2101d9
|
data/lib/rocket_job/job.rb
CHANGED
@@ -234,6 +234,11 @@ module RocketJob
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
+
# Returns a human readable duration the job has taken
|
238
|
+
def duration
|
239
|
+
seconds_as_duration(seconds)
|
240
|
+
end
|
241
|
+
|
237
242
|
# A job has expired if the expiry time has passed before it is started
|
238
243
|
def expired?
|
239
244
|
started_at.nil? && expires_at && (expires_at < Time.now)
|
@@ -241,7 +246,7 @@ module RocketJob
|
|
241
246
|
|
242
247
|
# Returns [Hash] status of this job
|
243
248
|
def as_json
|
244
|
-
attrs = serializable_hash(methods: :seconds)
|
249
|
+
attrs = serializable_hash(methods: [:seconds, :duration])
|
245
250
|
attrs.delete('result') unless collect_output?
|
246
251
|
case
|
247
252
|
when running?
|
@@ -268,9 +273,7 @@ module RocketJob
|
|
268
273
|
|
269
274
|
def status(time_zone='Eastern Time (US & Canada)')
|
270
275
|
h = as_json
|
271
|
-
|
272
|
-
h['duration'] = seconds_as_duration(seconds)
|
273
|
-
end
|
276
|
+
h.delete('seconds')
|
274
277
|
h.delete('perform_method') if h['perform_method'] == :perform
|
275
278
|
h.dup.each_pair do |k,v|
|
276
279
|
case
|
@@ -317,11 +320,13 @@ module RocketJob
|
|
317
320
|
|
318
321
|
def before_complete
|
319
322
|
self.percent_complete = 100
|
320
|
-
self.completed_at
|
323
|
+
self.completed_at = Time.now
|
324
|
+
self.worker_name = nil
|
321
325
|
end
|
322
326
|
|
323
327
|
def before_fail
|
324
328
|
self.completed_at = Time.now
|
329
|
+
self.worker_name = nil
|
325
330
|
end
|
326
331
|
|
327
332
|
def before_retry
|
@@ -330,6 +335,7 @@ module RocketJob
|
|
330
335
|
|
331
336
|
def before_pause
|
332
337
|
self.completed_at = Time.now
|
338
|
+
self.worker_name = nil
|
333
339
|
end
|
334
340
|
|
335
341
|
def before_resume
|
@@ -338,13 +344,14 @@ module RocketJob
|
|
338
344
|
|
339
345
|
def before_abort
|
340
346
|
self.completed_at = Time.now
|
347
|
+
self.worker_name = nil
|
341
348
|
end
|
342
349
|
|
343
350
|
# Returns a human readable duration from the supplied [Float] number of seconds
|
344
351
|
def seconds_as_duration(seconds)
|
345
352
|
time = Time.at(seconds)
|
346
353
|
if seconds >= 1.day
|
347
|
-
"#{seconds / 1.day}d #{time.strftime('%-Hh %-Mm %-Ss')}"
|
354
|
+
"#{(seconds / 1.day).to_i}d #{time.strftime('%-Hh %-Mm %-Ss')}"
|
348
355
|
elsif seconds >= 1.hour
|
349
356
|
time.strftime('%-Hh %-Mm %-Ss')
|
350
357
|
elsif seconds >= 1.minute
|
data/lib/rocket_job/version.rb
CHANGED
data/test/job_worker_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketjob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|