- @svg = ProvenanceHelper::create_provenance_graph nodes,
- "provenance_svg",
- {
- :request => request,
- :direction => :top_down,
- }
+
+ if nodes.length == 0
+ nodes[cr[:uuid]] = cr
+ end
+
+ pdh_to_col = {} # Indexed by PDH
+ output_pdhs = []
+
+ # Batch requests to get all related collections
+ # First fetch output collections by UUID.
+ Collection.filter([['uuid', 'in', col_uuids.uniq]]).with_count("none").each do |c|
+ output_pdhs << c[:portable_data_hash]
+ pdh_to_col[c[:portable_data_hash]] = c
+ nodes[c[:uuid]] = c
+ end
+ # Next, get input collections by PDH.
+ Collection.filter(
+ [['portable_data_hash', 'in', col_pdhs - output_pdhs]]).with_count("none").each do |c|
+ nodes[c[:portable_data_hash]] = c
+ end
+
+ @svg = ProvenanceHelper::create_provenance_graph(
+ nodes, "provenance_svg",
+ {
+ :request => request,
+ :pdh_to_uuid => pdh_to_col,
+ }
+ )