Class: HostStatus::ExecutionStatus
- Inherits:
-
Status
- Object
- Status
- HostStatus::ExecutionStatus
- Defined in:
- app/models/host_status/execution_status.rb
Defined Under Namespace
Classes: ExecutionTaskStatusMapper
Constant Summary collapse
- OK =
execution finished successfully
0
- ERROR =
execution finished with error
1
- QUEUED =
execution hasn’t started yet, either scheduled to future or executor didn’t create task yet
2
- RUNNING =
execution is in progress, dynflow task was created
3
- CANCELLED =
execution has been cancelled
4
- STATUS_NAMES =
mapping to string representation
{ OK => 'succeeded', ERROR => 'failed', QUEUED => 'queued', RUNNING => 'running', CANCELLED => 'cancelled' }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #relevant?(*args) ⇒ Boolean
- #status_link ⇒ Object
- #to_global(options = {}) ⇒ Object
- #to_label(options = {}) ⇒ Object
- #to_status(options = {}) ⇒ Object
Class Method Details
.status_name ⇒ Object
35 36 37 |
# File 'app/models/host_status/execution_status.rb', line 35 def self.status_name N_('Execution') end |
Instance Method Details
#relevant?(*args) ⇒ Boolean
15 16 17 |
# File 'app/models/host_status/execution_status.rb', line 15 def relevant?(*args) host.get_status(HostStatus::ExecutionStatus).present? end |
#status_link ⇒ Object
52 53 54 55 56 57 58 |
# File 'app/models/host_status/execution_status.rb', line 52 def status_link job_invocation = last_stopped_task&.parent_task&.job_invocations&.first return unless job_invocation return nil unless User.current.can?(:view_job_invocations, job_invocation) Rails.application.routes.url_helpers.job_invocation_path(job_invocation) end |
#to_global(options = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/host_status/execution_status.rb', line 27 def to_global( = {}) if to_status() == ERROR return HostStatus::Global::ERROR else return HostStatus::Global::OK end end |
#to_label(options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/host_status/execution_status.rb', line 39 def to_label( = {}) case to_status() when OK N_('Last execution succeeded') when CANCELLED N_('Last execution cancelled') when ERROR N_('Last execution failed') else N_('Unknown execution status') end end |
#to_status(options = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/host_status/execution_status.rb', line 19 def to_status( = {}) if self.new_record? ExecutionTaskStatusMapper.new(last_stopped_task).status else self.status end end |