Class: HostStatus::ExecutionStatus::ExecutionTaskStatusMapper
- Inherits:
-
Object
- Object
- HostStatus::ExecutionStatus::ExecutionTaskStatusMapper
- Defined in:
- app/models/host_status/execution_status.rb
Instance Attribute Summary collapse
-
#task ⇒ Object
Returns the value of attribute task.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(task) ⇒ ExecutionTaskStatusMapper
constructor
A new instance of ExecutionTaskStatusMapper.
- #status ⇒ Object
- #status_label ⇒ Object
Constructor Details
#initialize(task) ⇒ ExecutionTaskStatusMapper
Returns a new instance of ExecutionTaskStatusMapper.
82 83 84 |
# File 'app/models/host_status/execution_status.rb', line 82 def initialize(task) self.task = task end |
Instance Attribute Details
#task ⇒ Object
Returns the value of attribute task.
61 62 63 |
# File 'app/models/host_status/execution_status.rb', line 61 def task @task end |
Class Method Details
.sql_conditions_for(status) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/host_status/execution_status.rb', line 63 def self.sql_conditions_for(status) status = STATUS_NAMES.key(status) if status.is_a?(String) case status when OK [ "foreman_tasks_tasks.state = 'stopped' AND foreman_tasks_tasks.result = 'success'" ] when CANCELLED [ "foreman_tasks_tasks.state = 'stopped' AND foreman_tasks_tasks.result = 'cancelled'" ] when ERROR [ "foreman_tasks_tasks.state = 'stopped' AND (foreman_tasks_tasks.result = 'error' OR foreman_tasks_tasks.result = 'warning')" ] when QUEUED [ "foreman_tasks_tasks.state = 'scheduled' OR foreman_tasks_tasks.state IS NULL" ] when RUNNING [ "foreman_tasks_tasks.state <> 'stopped'" ] else [ '1 = 0' ] end end |
Instance Method Details
#status ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/models/host_status/execution_status.rb', line 86 def status if task.nil? || task.state == 'scheduled' QUEUED elsif task.state == 'stopped' && task.result == 'success' OK elsif task.state == 'stopped' && task.result == 'cancelled' CANCELLED elsif task.pending? RUNNING else ERROR end end |
#status_label ⇒ Object
100 101 102 |
# File 'app/models/host_status/execution_status.rb', line 100 def status_label STATUS_NAMES[status] end |