5554: Workbench links finished job logs from pipeline instance log tab.
[arvados.git] / apps / workbench / app / models / job.rb
1 class Job < ArvadosBase
2   def self.goes_in_projects?
3     true
4   end
5
6   def content_summary
7     "#{script} job"
8   end
9
10   def editable_attributes
11     %w(description)
12   end
13
14   def default_name
15     if script
16       x = "\"#{script}\" job"
17     else
18       x = super
19     end
20     if finished_at
21       x += " finished #{finished_at.strftime('%b %-d')}"
22     elsif started_at
23       x += " started #{started_at.strftime('%b %-d')}"
24     elsif created_at
25       x += " submitted #{created_at.strftime('%b %-d')}"
26     end
27   end
28
29   def cancel
30     arvados_api_client.api "jobs/#{self.uuid}/", "cancel", {}
31   end
32
33   def self.queue_size
34     arvados_api_client.api("jobs/", "queue_size", {"_method"=> "GET"})[:queue_size] rescue 0
35   end
36
37   def self.queue
38     arvados_api_client.unpack_api_response arvados_api_client.api("jobs/", "queue", {"_method"=> "GET"})
39   end
40
41   def textile_attributes
42     [ 'description' ]
43   end
44 end