1 class PipelineInvocation < OrvosModel
4 include CommonApiTemplate
5 serialize :components, Hash
6 belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
7 attr_accessor :pipeline
9 before_validation :bootstrap_components
10 before_validation :update_success
12 api_accessible :superuser, :extend => :common do |t|
14 t.add :pipeline, :if => :pipeline
23 dependency_search(self.components).keys
30 components['steps'].collect do |step|
32 row = [nrow, step['name']]
33 if step['complete'] and step['complete'] != 0
34 if step['output_data_locator']
45 row << (step['warehousejob']['id'] rescue nil)
46 row << (step['warehousejob']['revision'] rescue nil)
47 row << step['output_data_locator']
48 row << (Time.parse(step['warehousejob']['finishtime']) rescue nil)
58 return 0 if t.size < 1
59 t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size
63 success.nil? and modified_at and Time.now - modified_at < 5.minutes
67 def bootstrap_components
68 if pipeline and (!components or components.empty?)
69 self.components = pipeline.components
74 if components and progress_ratio == 1.0
79 def dependency_search(haystack)
80 if haystack.is_a? String
81 if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
86 elsif haystack.is_a? Array
88 haystack.each do |value|
89 deps.merge! dependency_search(value)
92 elsif haystack.respond_to? :keys
94 haystack.each do |key, value|
95 deps.merge! dependency_search(value)