web47core 3.2.6 → 3.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app/models/command_job.rb +14 -2
- data/lib/web47core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a2f6513fc3ea7307fc8b715807aaeef3ac0c63151bec753ecde3e5233742da5
|
4
|
+
data.tar.gz: 2d27d9d04e23dfd8e71ae2f6fb6080567cbab65f1af0f98ce09c5a34f0e90dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42801f50f150d8d47db4833cd7c5aff6a7f4743cd6a60797000c331f1815cc57ce6f844933dc7424343962f3363c3b0d9af0a2ac257dd0ff2c6bd1c9ca0a232c
|
7
|
+
data.tar.gz: 8fca8b55c877d788266c5628b59d820b0e147393fd138db16e8bca762dd2a396801fd0701b7a32e0cc56b4fa5c6ae97e45597701f1714787f1892987608378bd
|
@@ -27,20 +27,32 @@ class CommandJob
|
|
27
27
|
field :error_message, type: String
|
28
28
|
field :started_at, type: Time
|
29
29
|
field :finished_at, type: Time
|
30
|
+
field :cancelled_at, type: Time
|
30
31
|
#
|
31
32
|
# Relationships
|
32
33
|
#
|
33
34
|
has_many :logs, class_name: 'CommandJobLog', dependent: :destroy
|
34
|
-
belongs_to :started_by,
|
35
|
+
belongs_to :started_by, polymorphic: true, optional: true, inverse_of: nil
|
36
|
+
belongs_to :cancelled_by, polymorphic: true, optional: true, inverse_of: nil
|
35
37
|
#
|
36
38
|
# Validations
|
37
39
|
#
|
38
40
|
validates :state, inclusion: { in: ALL_STATES }
|
39
41
|
|
42
|
+
# @abstract cancel the current job
|
43
|
+
def cancel!(actor)
|
44
|
+
update! cancelled_by: actor, cancelled_at: Time.now.utc, state: STATE_CANCELLED
|
45
|
+
child_jobs.map { |j| j.cancel!(actor) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def child_jobs
|
49
|
+
[]
|
50
|
+
end
|
51
|
+
|
40
52
|
# @abstract duration for the job
|
41
53
|
# @return Integer - How long this job took in milliseconds
|
42
54
|
def duration
|
43
|
-
finished_at - started_at
|
55
|
+
succeeded? ? finished_at - started_at : 0
|
44
56
|
rescue StandardError
|
45
57
|
0
|
46
58
|
end
|
data/lib/web47core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web47core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schroeder
|
@@ -501,7 +501,7 @@ dependencies:
|
|
501
501
|
- !ruby/object:Gem::Version
|
502
502
|
version: '0'
|
503
503
|
- !ruby/object:Gem::Dependency
|
504
|
-
name:
|
504
|
+
name: simplecov_lcov_formatter
|
505
505
|
requirement: !ruby/object:Gem::Requirement
|
506
506
|
requirements:
|
507
507
|
- - ">="
|