From 4b6f27e5dbc306379ec9d4edd5ccda7f803f62dd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 9 Jul 2013 19:06:25 -0400 Subject: [PATCH] show provenance --- .../app/controllers/collections_controller.rb | 20 ++++++++++++++++++- .../app/views/collections/show.html.erb | 12 +++++------ services/api/app/models/job.rb | 3 +-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index bad1378622..71e882c5ee 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -49,7 +49,25 @@ class CollectionsController < ApplicationController @sourcedata = {params[:uuid] => {uuid: params[:uuid]}} @protected = {} - # TODO: compile provenance data using Job.where(...) + colorindex = -1 + any_hope_left = true + while any_hope_left + any_hope_left = false + Job.where(output: @sourcedata.keys).sort_by { |a| a.finished_at || a.created_at }.reverse.each do |job| + if !@output2colorindex[job.output] + any_hope_left = true + @output2colorindex[job.output] = (colorindex += 1) % 10 + @provenance << {job: job, output: job.output} + @sourcedata.delete job.output + @output2job[job.output] = job + job.dependencies.each do |new_source_data| + unless @output2colorindex[new_source_data] + @sourcedata[new_source_data] = {uuid: new_source_data} + end + end + end + end + end Link.where(head_uuid: @sourcedata.keys | @output2job.keys).each do |link| if link.link_class == 'resources' and link.name == 'wants' diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb index f8f9c0c8fb..8c6b420998 100644 --- a/apps/workbench/app/views/collections/show.html.erb +++ b/apps/workbench/app/views/collections/show.html.erb @@ -60,18 +60,16 @@ <% j.script_parameters.each do |k,v| %> - <% re = v.match(/^([0-9a-f]+)/) %> - <% justhash = (re and re[1].length == 32) ? re[1] : nil %> - <% if justhash and @output2job.has_key? justhash %> + <% if v and @output2job.has_key? v %> <%= v %> - <% elsif justhash %> - <%= justhash %>
<%= v %> + <% elsif v %> + <%= v %>
<%= v %> <% else %> <%= v %> <% end %> - <% if justhash - if @protected[justhash] + <% if v + if @protected[v] labelclass = 'success' labeltext = 'keep' else diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb index 5d520007d1..bb67bda97a 100644 --- a/services/api/app/models/job.rb +++ b/services/api/app/models/job.rb @@ -78,8 +78,7 @@ class Job < ArvadosModel self.script_parameters.values.each do |v| next unless v.is_a? String v.match(/^(([0-9a-f]{32})\b(\+[^,]+)?,?)*$/) do |locator| - bare_locator = locator[0].gsub(/\+[^,]+/,'') - deps[bare_locator] = true + deps[locator] = true end end deps.keys -- 2.30.2