Method: WorkflowManager::Server#update_time_status

Defined in:
lib/workflow_manager/server.rb

#update_time_status(job_id, current_status, script_name, user, project_number) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/workflow_manager/server.rb', line 263

def update_time_status(job_id, current_status, script_name, user, project_number)
  # if the current status changed from last time, then save, otherwise do nothing
  # once status changes into success or fail, then the thread is expected to be killed in later process
  @statuses.transaction do |statuses|
    start_time = nil
    if stat = statuses[job_id] 
      last_status, script_name, start_time, user, project_number = stat.split(/,/)
    end
    time = if start_time 
             if current_status == 'success' or current_status == 'fail'
               start_time + '/' + Time.now.strftime("%Y-%m-%d %H:%M:%S")
             elsif current_status != last_status
               Time.now.strftime("%Y-%m-%d %H:%M:%S")
             end
           else
             Time.now.strftime("%Y-%m-%d %H:%M:%S")
           end
    if time
      statuses[job_id] = [current_status, script_name, time, user, project_number].join(',')
    end
  end
end