From: Peter Amstutz Date: Thu, 21 Aug 2014 18:44:30 +0000 (-0400) Subject: 3036: Use preload_objects to fetch owner_uuids in the controller instead of in the... X-Git-Tag: 1.1.0~2275^2~15 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/5b7762f1e6931c3e4e6ccd36d2a75ce53e38e36c?hp=6403b8728d3120d6cb22583b3963d2a030e88aa3 3036: Use preload_objects to fetch owner_uuids in the controller instead of in the view. --- diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index a4925bdeb3..1cc4966ac8 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -170,6 +170,14 @@ class CollectionsController < ApplicationController .where(head_uuid: @object.uuid, link_class: 'name').results project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).to_hash @projects = project_hash.values + + if @object.uuid.match /[0-9a-f]{32}/ + @same_pdh = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]) + owners = @same_pdh.map {|s| s.owner_uuid}.to_a + preload_objects_for_dataclass Group, owners + preload_objects_for_dataclass User, owners + end + @permissions = Link.limit(RELATION_LIMIT).order("modified_at DESC") .where(head_uuid: @object.uuid, link_class: 'permission', name: 'can_read').results diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb index cc19000725..7d8ac4dacb 100644 --- a/apps/workbench/app/views/collections/show.html.erb +++ b/apps/workbench/app/views/collections/show.html.erb @@ -35,11 +35,11 @@
- <% if @object.uuid.match /[0-9a-f]{32}/ %> + <% if defined? @same_pdh %>

Found in collections:

- <% cols = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]).each do |c| %> - <%= link_to_if_arvados_object c.owner_uuid, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %>
+ <% @same_pdh.each do |c| %> + <%= link_to_if_arvados_object get_object(c.owner_uuid), {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %>
<% end %>

<% else %>