add PipelineInvocation#active, and try to set success=false when needed
authorTom Clegg <tom@clinicalfuture.com>
Tue, 29 Jan 2013 02:27:21 +0000 (18:27 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 29 Jan 2013 02:27:21 +0000 (18:27 -0800)
app/models/pipeline_invocation.rb

index 113411f9a74624fb16683e8b7155194e280e71d3..06e714d6ed196931fa3e748f0b3fb7894bdf3312 100644 (file)
@@ -30,10 +30,17 @@ class PipelineInvocation < OrvosModel
       components['steps'].collect do |step|
         nrow += 1
         row = [nrow, step['name']]
-        if step['output_data_locator']
-          row << 1.0
+        if step['complete'] and step['complete'] != 0
+          if step['output_data_locator']
+            row << 1.0
+          else
+            row << 0.0
+          end
         else
           row << 0.0
+          if step['failed']
+            self.success = false
+          end
         end
         row << (step['warehousejob']['id'] rescue nil)
         row << (step['warehousejob']['revision'] rescue nil)
@@ -52,6 +59,10 @@ class PipelineInvocation < OrvosModel
     t.collect { |r| r[2] }.inject(0.0) { |sum,a| sum += a } / t.size
   end
 
+  def active
+    success.nil? and Time.now - modified_at < 5.minutes
+  end
+
   protected
   def bootstrap_components
     if pipeline and (!components or components.empty?)