+ def child_summary
+ done = 0
+ failed = 0
+ todo = 0
+ running = 0
+ children.each do |c|
+ case c.state_label
+ when 'Complete'
+ done = done+1
+ when 'Failed', 'Cancelled'
+ failed = failed+1
+ when 'Running'
+ running = running+1
+ else
+ todo = todo+1
+ end
+ end
+
+ summary = {}
+ summary[:done] = done
+ summary[:failed] = failed
+ summary[:todo] = todo
+ summary[:running] = running
+ summary
+ end
+
+ def child_summary_str
+ summary = child_summary
+ summary_txt = ''
+
+ if state_label == 'Running'
+ done = summary[:done] || 0
+ running = summary[:running] || 0
+ failed = summary[:failed] || 0
+ todo = summary[:todo] || 0
+ total = done + running + failed + todo
+
+ if total > 0
+ summary_txt += "#{summary[:done]} #{'child'.pluralize(summary[:done])} done,"
+ summary_txt += "#{summary[:failed]} failed,"
+ summary_txt += "#{summary[:running]} running,"
+ summary_txt += "#{summary[:todo]} pending"
+ end
+ end
+ summary_txt
+ end
+
+ def progress
+ state = state_label
+ if state == 'Complete'
+ return 1.0
+ elsif state == 'Failed' or state == 'Cancelled'
+ return 0.0
+ end
+
+ summary = child_summary
+ return 0.0 if summary.nil?
+
+ done = summary[:done] || 0
+ running = summary[:running] || 0
+ failed = summary[:failed] || 0
+ todo = summary[:todo] || 0
+ total = done + running + failed + todo
+ if total > 0
+ (done+failed).to_f / total
+ else
+ 0.0
+ end
+ end
+
+ def children
+ []
+ end
+
+ def outputs
+ []
+ end
+
+ def title
+ "process"
+ end
+
+ def has_unreadable_children
+ @unreadable_children
+ end
+
+ def readable?
+ resource_class = ArvadosBase::resource_class_for_uuid(uuid)
+ resource_class.where(uuid: [uuid]).first rescue nil
+ end
+
+ def link_to_log
+ if state_label.in? ["Complete", "Failed", "Cancelled"]
+ lc = log_collection
+ if lc
+ logCollection = Collection.find? lc
+ if logCollection
+ ApplicationController.helpers.link_to("Log", "#{uri}#Log")
+ else
+ "Log unavailable"
+ end
+ end
+ elsif state_label == "Running"
+ if readable?
+ ApplicationController.helpers.link_to("Log", "#{uri}#Log")
+ else
+ "Log unavailable"
+ end
+ end
+ end
+
+ def walltime
+ if state_label != "Queued"
+ if started_at
+ ((if finished_at then finished_at else Time.now() end) - started_at)
+ end
+ end
+ end
+
+ def cputime
+ if state_label != "Queued"
+ if started_at
+ (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
+ end
+ end
+ end
+
+ def queuedtime
+ if state_label == "Queued"
+ Time.now - Time.parse(created_at.to_s)
+ end