From 39755f7642bf974e6e2e1cf3828b5240f489566c Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 4 May 2017 18:37:09 -0300 Subject: [PATCH] 10111: Better labels on collection on the provenance graph. --- .../app/helpers/provenance_helper.rb | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb index 782639bedd..fc2ce1d263 100644 --- a/apps/workbench/app/helpers/provenance_helper.rb +++ b/apps/workbench/app/helpers/provenance_helper.rb @@ -104,6 +104,27 @@ module ProvenanceHelper gr end + def col_name_for_project(col_pdh, project_uuid) + [ + # Search for collections within the same project first. + {portable_data_hash: col_pdh, owner_uuid: project_uuid}, + # then, earch for collections in any project. + {portable_data_hash: col_pdh}, + ].each do |query_args| + col = Collection.where(query_args).limit(1) + if col.results.any? + if col.items_available == 1 + return col.results.first.name + else + return col.results.first.name + " + #{col.items_available - 1} more" + end + end + end + + # No collections found with this pdh + col_pdh + end + def cr_edges cr uuid = cr[:uuid] gr = "" @@ -114,7 +135,8 @@ module ProvenanceHelper ProvenanceHelper::find_collections input_obj, 'input' do |col_hash, col_uuid, key| # Only include input PDHs if col_hash - gr += describe_node(col_hash) + gr += describe_node(col_hash, + {label: col_name_for_project(col_hash, cr[:owner_uuid])}) gr += edge(col_hash, uuid, {:label => key}) end end @@ -124,7 +146,8 @@ module ProvenanceHelper if cr[:output_uuid] output_pdh = Collection.find(cr[:output_uuid])[:portable_data_hash] if output_pdh - gr += describe_node(output_pdh) + gr += describe_node(output_pdh, + {label: col_name_for_project(output_pdh, cr[:owner_uuid])}) gr += edge(uuid, output_pdh, {label: 'output'}) end end -- 2.30.2