10079: add "parent" to work_unit to aid the child display
[arvados.git] / apps / workbench / app / models / job.rb
index 3ece865959f10aabf70acfab6cde1dd9145cf6d5..7bfed6d44b5c089fb9ecc518362e026e787762f4 100644 (file)
@@ -41,4 +41,19 @@ class Job < ArvadosBase
   def textile_attributes
     [ 'description' ]
   end
+
+  def stderr_log_query(limit=nil)
+    query = Log.where(object_uuid: self.uuid).order("created_at DESC")
+    query = query.limit(limit) if limit
+    query
+  end
+
+  def stderr_log_lines(limit=2000)
+    stderr_log_query(limit).results.reverse.
+      flat_map { |log| log.properties[:text].split("\n") rescue [] }
+  end
+
+  def work_unit(label=nil)
+    JobWorkUnit.new(self, label, self.uuid)
+  end
 end