Class: Toaster::AutomationRun
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Toaster::AutomationRun
- Defined in:
- lib/toaster/model/automation_run.rb
Constant Summary collapse
- @@current_run =
nil
Class Method Summary collapse
- .find(criteria = {}) ⇒ Object
-
.get_current ⇒ Object
used in the context of a currently active run.
-
.set_current(run) ⇒ Object
used in the context of a currently active run.
Instance Method Summary collapse
- #duration ⇒ Object
- #get_executed_tasks ⇒ Object
- #get_flat_attributes ⇒ Object
- #get_num_task_executions ⇒ Object
- #get_task_execution(task) ⇒ Object
-
#initialize(attr_hash) ⇒ AutomationRun
constructor
FIELDS: :uuid, :machine_id, :automation, :start_time, :end_time, :success, :error_details, :attributes.
- #task_execution_index(task_exec) ⇒ Object
Constructor Details
#initialize(attr_hash) ⇒ AutomationRun
FIELDS:
:uuid, :machine_id, :automation, :start_time,
:end_time, :success, :error_details, :attributes
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/toaster/model/automation_run.rb', line 28 def initialize(attr_hash) if !attr_hash[:uuid] attr_hash[:uuid] = Util.generate_short_uid() end if !attr_hash[:start_time] attr_hash[:start_time] = TimeStamp.now.to_i end if !attr_hash[:machine_id] attr_hash[:machine_id] = Util.get_machine_id() end super(attr_hash) end |
Class Method Details
.find(criteria = {}) ⇒ Object
89 90 91 |
# File 'lib/toaster/model/automation_run.rb', line 89 def self.find(criteria={}) DB.find_activerecord(AutomationRun, criteria) end |
.get_current ⇒ Object
used in the context of a currently active run
42 43 44 |
# File 'lib/toaster/model/automation_run.rb', line 42 def self.get_current return @@current_run end |
.set_current(run) ⇒ Object
used in the context of a currently active run
46 47 48 49 |
# File 'lib/toaster/model/automation_run.rb', line 46 def self.set_current(run) run.save @@current_run = run end |
Instance Method Details
#duration ⇒ Object
84 85 86 87 |
# File 'lib/toaster/model/automation_run.rb', line 84 def duration return nil if !end_time || !start_time return end_time - start_time end |
#get_executed_tasks ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/toaster/model/automation_run.rb', line 55 def get_executed_tasks() result = [] task_executions.each do |exec| result << exec.task end return result end |
#get_flat_attributes ⇒ Object
51 52 53 |
# File 'lib/toaster/model/automation_run.rb', line 51 def get_flat_attributes() KeyValuePair.get_as_hash(run_attributes) end |
#get_num_task_executions ⇒ Object
63 64 65 |
# File 'lib/toaster/model/automation_run.rb', line 63 def get_num_task_executions() return task_executions.size end |
#get_task_execution(task) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/toaster/model/automation_run.rb', line 67 def get_task_execution(task) task_executions().each do |e| if e.task.uuid == task.uuid return e end end end |
#task_execution_index(task_exec) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/toaster/model/automation_run.rb', line 75 def task_execution_index(task_exec) task_executions().each_with_index do |e,idx| if e.uuid == task_exec.uuid return idx end end return nil end |