-<%
- failed = j[:tasks_summary][:failed] || 0 rescue 0
- done = j[:tasks_summary][:done] || 0 rescue 0
- running = j[:tasks_summary][:running] || 0 rescue 0
- todo = j[:tasks_summary][:todo] || 0 rescue 0
-
- if j[:success] == false and done + running + failed == 0
- # The job failed but no tasks were ever started (i.e. crunch-dispatch
- # was unable to start the job). Display a full 100% failed progress bar.
- failed_percent = 100
- success_percent = 0
- running_percent = 0
- elsif done + running + failed + todo == 0
- # No tasks were ever created for this job;
- # render an empty progress bar.
- failed_percent = 0
- success_percent = 0
- running_percent = 0
- else
- percent_total_tasks = 100.0 / (done + running + failed + todo)
- if defined? scaleby
- percent_total_tasks *= scaleby
- end
- failed_percent = (failed * percent_total_tasks).ceil
- success_percent = (done * percent_total_tasks).ceil
- running_percent = (running * percent_total_tasks).ceil
-
- # We used ceil instead of round to compute percents to handle the situation
- # where one of them is much larger than the other(s). However, this may
- # have resulted in total percent > 100, hence we need to account for that.
- if (failed_percent + success_percent + running_percent) > 100
- overflow = failed_percent + success_percent + running_percent - 100
- # decrease the biggest by the overlow amount
- if (failed_percent > success_percent) && (failed_percent > running_percent)
- failed_percent -= overflow
- elsif (success_percent > failed_percent) && (success_percent > running_percent)
- success_percent -= overflow
- else
- running_percent -= overflow
- end
- end
- end
-%>
+<% if (j.andand[:state] == "Running" or defined? scaleby) and (not defined? show_progress_bar or show_progress_bar) %>
+ <%
+ failed = j[:tasks_summary][:failed] || 0 rescue 0
+ done = j[:tasks_summary][:done] || 0 rescue 0
+ running = j[:tasks_summary][:running] || 0 rescue 0
+ todo = j[:tasks_summary][:todo] || 0 rescue 0