8650: add children to container_work_unit
[arvados.git] / apps / workbench / app / models / job_work_unit.rb
1 class JobWorkUnit < ProxyWorkUnit
2   def children
3     return self.my_children if self.my_children
4
5     # Jobs components
6     items = []
7     components = get(:components)
8     uuids = components.andand.collect {|_, v| v}
9     return items if (!uuids or uuids.empty?)
10
11     rcs = {}
12     uuids.each do |u|
13       r = ArvadosBase::resource_class_for_uuid(u)
14       rcs[r] = [] unless rcs[r]
15       rcs[r] << u
16     end
17     rcs.each do |rc, ids|
18       rc.where(uuid: ids).each do |obj|
19         items << obj.work_unit(components.key(obj.uuid))
20       end
21     end
22
23     self.my_children = items
24   end
25
26   def child_summary
27     if children.any?
28       super
29     else
30       get(:tasks_summary)
31     end
32   end
33
34   def can_cancel?
35     true
36   end
37
38   def uri
39     uuid = get(:uuid)
40     "/jobs/#{uuid}"
41   end
42
43   def title
44     "job"
45   end
46 end