From c94b5e1dd6055687940390a4ad2a6e08b43c4a5f Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 14 Jan 2013 12:24:23 -0800 Subject: [PATCH] add pipeline_invocations html view --- .../pipeline_invocations_controller.rb | 5 ++ app/models/pipeline_invocation.rb | 36 +++++++++++ app/views/pipeline_invocations/index.html.erb | 64 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 app/controllers/pipeline_invocations_controller.rb create mode 100644 app/views/pipeline_invocations/index.html.erb diff --git a/app/controllers/pipeline_invocations_controller.rb b/app/controllers/pipeline_invocations_controller.rb new file mode 100644 index 0000000000..de8b9eb6ce --- /dev/null +++ b/app/controllers/pipeline_invocations_controller.rb @@ -0,0 +1,5 @@ +class PipelineInvocationsController < ApplicationController + def index + @objects = model_class.order("created_at desc") + end +end diff --git a/app/models/pipeline_invocation.rb b/app/models/pipeline_invocation.rb index 96deabbc7b..98b5494461 100644 --- a/app/models/pipeline_invocation.rb +++ b/app/models/pipeline_invocation.rb @@ -4,6 +4,36 @@ class PipelineInvocation < ActiveRecord::Base belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid before_validation :bootstrap_components + before_validation :update_success + + def progress_table + begin + # v0 pipeline format + nrow = -1 + components['steps'].collect do |step| + nrow += 1 + row = [nrow, step['name']] + if step['output_data_locator'] + row << 1.0 + else + row << 0.0 + end + row << (step['warehousejob']['id'] rescue nil) + row << (step['warehousejob']['revision'] rescue nil) + row << step['output_data_locator'] + row << (Time.parse(step['warehousejob']['finishtime']) rescue nil) + row + end + rescue + [] + end + end + + def progress_ratio + t = progress_table + return 0 if t.size < 1 + t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size + end protected def bootstrap_components @@ -11,4 +41,10 @@ class PipelineInvocation < ActiveRecord::Base self.components = pipeline.components end end + + def update_success + if components and progress_ratio == 1.0 + self.success = true + end + end end diff --git a/app/views/pipeline_invocations/index.html.erb b/app/views/pipeline_invocations/index.html.erb new file mode 100644 index 0000000000..0a841b64f0 --- /dev/null +++ b/app/views/pipeline_invocations/index.html.erb @@ -0,0 +1,64 @@ + + + + + + <% @objects.each do |o| %> + + <% status = o.success ? 'success' : (o.success == false ? 'failure' : 'pending') %> + + + + + + <% if %> + + + + + <% end %> + <% end %> +
+ success + + active + + % complete + + uuid + + pipeline uuid + + name + + last updated +
+ <%= status %> + + <%= o.active ? 'yes' : '-' %> + + <%= (o.progress_ratio * 1000).floor / 10 %> + + <%= o.uuid %> + + <%= o.pipeline_uuid %> + + <%= o.name %> + + <%= distance_of_time_in_words(o.updated_at, Time.now, true) + ' ago' if o.updated_at %> +
+ + <% o.progress_table.each do |r| %> + + <% r[2] = "#{(r[2]*100).floor}%" %> + <% r[4] = r[4][0..5] rescue '' %> + <% r.each do |c| %> + + <% end %> + + <% end %> +
+ <%= (c.is_a? Time) ? distance_of_time_in_words(c, Time.now, true) + ' ago' : c %> +
+ +
-- 2.30.2