From 5ee5b90b5d7554d049c9071ed7bb812d1b7ca74a Mon Sep 17 00:00:00 2001 From: radhika Date: Mon, 22 Sep 2014 13:09:02 -0400 Subject: [PATCH] 3381: address the situation where sum percentages calculated exceeded 100% --- .../app/views/application/_job_progress.html.erb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/workbench/app/views/application/_job_progress.html.erb b/apps/workbench/app/views/application/_job_progress.html.erb index 5c19779ccc..f942c44c2c 100644 --- a/apps/workbench/app/views/application/_job_progress.html.erb +++ b/apps/workbench/app/views/application/_job_progress.html.erb @@ -24,6 +24,21 @@ 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 %> -- 2.30.2