10079: add "parent" to work_unit to aid the child display
[arvados.git] / apps / workbench / app / models / job.rb
index 977eef91bf278ac5e9a528e935262dce478e4fa5..7bfed6d44b5c089fb9ecc518362e026e787762f4 100644 (file)
@@ -7,16 +7,8 @@ class Job < ArvadosBase
     "#{script} job"
   end
 
-  def attribute_editable? attr, *args
-    if attr.to_sym == :description
-      super && attr.to_sym == :description
-    else
-      false
-    end
-  end
-
-  def self.creatable?
-    false
+  def editable_attributes
+    %w(description)
   end
 
   def default_name
@@ -42,11 +34,26 @@ class Job < ArvadosBase
     arvados_api_client.api("jobs/", "queue_size", {"_method"=> "GET"})[:queue_size] rescue 0
   end
 
-  def self.queue 
+  def self.queue
     arvados_api_client.unpack_api_response arvados_api_client.api("jobs/", "queue", {"_method"=> "GET"})
   end
 
   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