web47command 0.0.2 → 0.0.3
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 +45 -10
- data/lib/web47command/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec04e840dab56171aaa7e29aab015888e461d1f2487f53dc854b86baebe799f
|
4
|
+
data.tar.gz: 2cf3644fbd84c46a0caaf5c271ebe293a4a608181bc3ef7ecf189a6090490e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1840d4ca423bb53b9b86e091f51ee146a444b7bf44dc2904a073f3e9fb8a3cbca247a93dc4d409177f83098ae4ae1ab8e371918f59671e524e054b0aecdb8180
|
7
|
+
data.tar.gz: 4fe65ce773a652b7cd77954fa35a2aff89d58e54dc00b72ef701f10303b6186b86595b6489560e75132610edc48fa935510702f8fe447d85fe31668a9d78d510
|
@@ -13,7 +13,10 @@ class CommandJob
|
|
13
13
|
STATE_RETRYING = 'retrying' unless defined? STATE_RETRYING
|
14
14
|
STATE_SUCCESS = 'success' unless defined? STATE_SUCCESS
|
15
15
|
STATE_FAIL = 'failure' unless defined? STATE_FAIL
|
16
|
-
|
16
|
+
STATE_CANCELLED = 'cancelled' unless defined? STATE_CANCELLED
|
17
|
+
unless defined? ALL_STATES
|
18
|
+
ALL_STATES = [STATE_NEW, STATE_WIP, STATE_RETRYING, STATE_CANCELLED, STATE_SUCCESS, STATE_FAIL].freeze
|
19
|
+
end
|
17
20
|
#
|
18
21
|
# Fields
|
19
22
|
#
|
@@ -48,43 +51,68 @@ class CommandJob
|
|
48
51
|
#
|
49
52
|
# True if in new status
|
50
53
|
#
|
51
|
-
def
|
54
|
+
def new_job?
|
52
55
|
STATE_NEW.eql?(state)
|
53
56
|
end
|
54
57
|
|
55
58
|
#
|
56
59
|
# True if in WIP status
|
57
60
|
#
|
58
|
-
def
|
61
|
+
def work_in_progress?
|
59
62
|
[STATE_RETRYING, STATE_WIP].include?(state)
|
60
63
|
end
|
61
64
|
|
62
65
|
#
|
63
66
|
# True if in success status
|
64
67
|
#
|
65
|
-
def
|
68
|
+
def succeeded?
|
66
69
|
STATE_SUCCESS.eql?(state)
|
67
70
|
end
|
68
71
|
|
69
72
|
#
|
70
73
|
# True if in fail status
|
71
74
|
#
|
72
|
-
def
|
75
|
+
def failed?
|
73
76
|
STATE_FAIL.eql?(state)
|
74
77
|
end
|
75
78
|
|
76
79
|
#
|
77
80
|
# If we is finished, failed or success
|
78
81
|
#
|
79
|
-
def
|
80
|
-
[STATE_FAIL, STATE_SUCCESS].include?(state)
|
82
|
+
def completed?
|
83
|
+
[STATE_CANCELLED, STATE_FAIL, STATE_SUCCESS].include?(state)
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Job has not finished, failure or success
|
88
|
+
#
|
89
|
+
def incomplete?
|
90
|
+
!completed?
|
81
91
|
end
|
82
92
|
|
93
|
+
alias running? incomplete?
|
94
|
+
|
83
95
|
#
|
84
|
-
# If we are
|
96
|
+
# If we are cancelled
|
85
97
|
#
|
86
|
-
def
|
87
|
-
|
98
|
+
def cancelled?
|
99
|
+
STATE_CANCELLED.eql?(state)
|
100
|
+
end
|
101
|
+
|
102
|
+
def job_cancelled?(job = self)
|
103
|
+
job.reload
|
104
|
+
job.cancelled?
|
105
|
+
rescue StandardError => error
|
106
|
+
App47Logger.log_warn "Unable to check job cancelled #{job}", error
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
110
|
+
def failure_or_cancelled?(job = self)
|
111
|
+
job.reload
|
112
|
+
job.failure? || job.cancelled?
|
113
|
+
rescue StandardError => error
|
114
|
+
App47Logger.log_warn "Unable to check job cancelled #{job}", error
|
115
|
+
true
|
88
116
|
end
|
89
117
|
|
90
118
|
#
|
@@ -266,4 +294,11 @@ class CommandJob
|
|
266
294
|
def add_log(message)
|
267
295
|
logs.create!(message: message)
|
268
296
|
end
|
297
|
+
|
298
|
+
#
|
299
|
+
# Which to sort by
|
300
|
+
#
|
301
|
+
def sort_fields
|
302
|
+
%i[created_at]
|
303
|
+
end
|
269
304
|
end
|
data/lib/web47command/version.rb
CHANGED