Merge branch 'master' into 5365-not-link-unreadables
[arvados.git] / apps / workbench / app / helpers / jobs_helper.rb
index 44c7bf621cff2affa9184a49e1d43072e5f6fac1..889dd23823b2c1050bc2f05ec2d69cc95900984c 100644 (file)
@@ -1,2 +1,22 @@
 module JobsHelper
+  def stderr_log_history(job_uuids, limit=2000)
+    results = []
+
+    log_history = Log.where(event_type: 'stderr',
+                            object_uuid: job_uuids).limit(limit).order('id DESC')
+    if !log_history.results.empty?
+      reversed_results = log_history.results.reverse
+      reversed_results.each do |entry|
+        if entry.andand.properties
+          properties = entry.properties
+          text = properties[:text]
+          if text
+            results = results.concat text.split("\n")
+          end
+        end
+      end
+    end
+    return results
+  end
+
 end