2 failed = j[:tasks_summary][:failed] || 0 rescue 0
3 done = j[:tasks_summary][:done] || 0 rescue 0
4 running = j[:tasks_summary][:running] || 0 rescue 0
5 todo = j[:tasks_summary][:todo] || 0 rescue 0
7 if j[:success] == false and done + running + failed == 0
8 # The job failed but no tasks were ever started (i.e. crunch-dispatch
9 # was unable to start the job). Display a full 100% failed progress bar.
13 elsif done + running + failed + todo == 0
14 # No tasks were ever created for this job;
15 # render an empty progress bar.
20 percent_total_tasks = 100.0 / (done + running + failed + todo)
22 percent_total_tasks *= scaleby
24 failed_percent = (failed * percent_total_tasks).ceil
25 success_percent = (done * percent_total_tasks).ceil
26 running_percent = (running * percent_total_tasks).ceil
28 # We used ceil instead of round to compute percents to handle the situation
29 # where one of them is much larger than the other(s). However, this may
30 # have resulted in total percent > 100, hence we need to account for that.
31 if (failed_percent + success_percent + running_percent) > 100
32 overflow = failed_percent + success_percent + running_percent - 100
33 # decrease the biggest by the overlow amount
34 if (failed_percent > success_percent) && (failed_percent > running_percent)
35 failed_percent -= overflow
36 elsif (success_percent > failed_percent) && (success_percent > running_percent)
37 success_percent -= overflow
39 running_percent -= overflow
45 <% if not defined? scaleby %>
46 <div class="progress">
49 <span class="progress-bar progress-bar-success" style="width: <%= success_percent %>%;">
51 <span class="progress-bar progress-bar-danger" style="width: <%= failed_percent %>%;">
53 <span class="progress-bar" style="width: <%= running_percent %>%;">
56 <% if not defined? scaleby %>