Browse Source

Show non-Agent run jobs as "(system)" instead of "(deleted)"

Akinori MUSHA 9 years ago
parent
commit
3b4e56d2af
2 changed files with 13 additions and 3 deletions
  1. 2 0
      app/helpers/jobs_helper.rb
  2. 11 3
      app/views/jobs/index.html.erb

+ 2 - 0
app/helpers/jobs_helper.rb

@@ -26,6 +26,8 @@ module JobsHelper
   def agent_from_job(job)
     if data = YAML.load(job.handler).try(:job_data)
       Agent.find_by_id(data['arguments'][0])
+    else
+      false
     end
   rescue ArgumentError
     # We can get to this point before all of the agents have loaded (usually,

+ 11 - 3
app/views/jobs/index.html.erb

@@ -20,11 +20,19 @@
           </tr>
 
         <% @jobs.each do |job| %>
-          <% agent = agent_from_job(job) %>
           <tr>
             <td><%= status(job) %></td>
-            <td><%= agent ? link_to(agent.name, agent_path(agent)) : "(deleted)" %></td>
-            <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago <%= agent ? "for #{agent.user.username}" : '' %></td>
+            <td><% case agent = agent_from_job(job)
+                   when Agent
+                   %><%= link_to(agent.name, agent_path(agent)) %><%
+                   when false
+                   %>(system)<%
+                   when nil
+                   %>(deleted)<%
+                   else
+                   %>(unknown)<%
+                   end %></td>
+            <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago<% if user = agent.try(:user) %> for <%= user.username %><% end %></td>
             <td title='<%= job.run_at %>'>
               <% if !job.failed_at %>
                 <%= relative_distance_of_time_in_words job.run_at %>