Merge branch '11629-groups-contents-memory'
[arvados.git] / apps / workbench / app / models / container_work_unit.rb
index 88aab306cedc8b9ea5a8a94a27cc394f2022780b..84fc1f8f0978e16a86bd34fde8d07a6d2d9cd7c1 100644 (file)
@@ -53,6 +53,10 @@ class ContainerWorkUnit < ProxyWorkUnit
     get(:container_uuid)
   end
 
+  def requesting_container_uuid
+    get(:requesting_container_uuid)
+  end
+
   def priority
     @proxied.priority
   end
@@ -81,8 +85,11 @@ class ContainerWorkUnit < ProxyWorkUnit
   def state_label
     ec = exit_code
     return "Failed" if (ec && ec != 0)
+
     state = get_combined(:state)
-    return "Ready" if ((priority == 0) and (["Queued", "Locked"].include?(state)))
+
+    return "Queued" if state == "Locked"
+    return "Cancelled" if ((priority == 0) and (state == "Queued"))
     state
   end
 
@@ -99,12 +106,21 @@ class ContainerWorkUnit < ProxyWorkUnit
   end
 
   def log_collection
-    get_combined(:log)
+    if @proxied.is_a?(ContainerRequest)
+      get(:log_uuid)
+    else
+      get(:log)
+    end
   end
 
   def outputs
     items = []
-    items << get_combined(:output) if get_combined(:output)
+    if @proxied.is_a?(ContainerRequest)
+      out = get(:output_uuid)
+    else
+      out = get(:output)
+    end
+    items << out if out
     items
   end
 
@@ -154,6 +170,13 @@ class ContainerWorkUnit < ProxyWorkUnit
 
   protected
   def get_combined key
-    get(key, @container) || get(key, @proxied)
+    from_container = get(key, @container)
+    from_proxied = get(key, @proxied)
+
+    if from_container.is_a? Hash or from_container.is_a? Array
+      if from_container.any? then from_container else from_proxied end
+    else
+      from_container || from_proxied
+    end
   end
 end