web47core 3.2.6 → 3.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09bd1177ff541dc974ea27c1208e06c43be1056962384b6250e52bfc2938fd6b'
4
- data.tar.gz: 119fcf27352d87d96ef84328e24cc7adbf6cbe1e18363a2535826e5bb5c3a90d
3
+ metadata.gz: 998801eca3b3e54c48a069b4d7314fefb4b65fb3ee79663614b6bad6143eb470
4
+ data.tar.gz: f51caf108f0c544036eb5f949c72a3dfae98bde64bc1a57ef3ef8ac874e516e5
5
5
  SHA512:
6
- metadata.gz: 38926fb70d61e60d8633fcd89e58d2a5e66dca47ac9245eeb31c3de8264917e547d13740819df61850805a06631b69b22929643310feb0a9458fbd893881d9cf
7
- data.tar.gz: 061e7c166c012d860b4c66521c2d178943197a1384c0f195ea331d13087b0a0801def262f28b85083c149388368d273cf04adf303632dcc8913b98c798ff036c
6
+ metadata.gz: fb14648cc706c95f806192e5a6e7bee71de7bae0d07666f45440ab52b0b0660585d9914aa2f21ccbcfde5c0e56365d0f09663c4d15819152665854de09f6fefc
7
+ data.tar.gz: 9a8eb01bd565a883fccac315eb76a6dff2ab0176eb4fa0cbe33e9ba7d5d0fda3549938a2ad42e8f1ec7565ea1003c97fc73fe75cee4f91d75a3b5278af871d23
@@ -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, class_name: 'User', optional: true
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) unless completed?
45
+ child_jobs.each { |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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '3.2.6'
4
+ VERSION = '3.2.8'
5
5
  end
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.6
4
+ version: 3.2.8
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: simplecov-lcov
504
+ name: simplecov_lcov_formatter
505
505
  requirement: !ruby/object:Gem::Requirement
506
506
  requirements:
507
507
  - - ">="