X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/642e59798974a4c3bb0ecfebd3fa790c912d1187..f308830adff32b6cccd7e0720dec20c42a1bed60:/apps/workbench/app/models/container_work_unit.rb diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb index 68f8e30093..a5b26f0d6d 100644 --- a/apps/workbench/app/models/container_work_unit.rb +++ b/apps/workbench/app/models/container_work_unit.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class ContainerWorkUnit < ProxyWorkUnit attr_accessor :container attr_accessor :child_proxies @@ -16,20 +20,16 @@ class ContainerWorkUnit < ProxyWorkUnit def children return @my_children if @my_children - container_uuid = nil - container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end - items = [] + container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end if container_uuid - my_children = @child_proxies cols = ContainerRequest.columns.map(&:name) - %w(id updated_at mounts) - my_children = ContainerRequest.select(cols).where(requesting_container_uuid: container_uuid).results if !my_children + my_children = @child_proxies || ContainerRequest.select(cols).where(requesting_container_uuid: container_uuid).results if !my_children my_child_containers = my_children.map(&:container_uuid).compact.uniq grandchildren = {} my_child_containers.each { |c| grandchildren[c] = []} if my_child_containers.any? - reqs = ContainerRequest.select(cols).where(requesting_container_uuid: my_child_containers).results if my_child_containers.any? - reqs.each {|cr| grandchildren[cr.request_container_uuid] << cr} if reqs + reqs.each {|cr| grandchildren[cr.requesting_container_uuid] << cr} if reqs my_children.each do |cr| items << cr.work_unit(cr.name || 'this container', child_objects=grandchildren[cr.container_uuid])