diff --git a/app/helpers/maintenance_tasks/tasks_helper.rb b/app/helpers/maintenance_tasks/tasks_helper.rb index a0c8307d..c408b6df 100644 --- a/app/helpers/maintenance_tasks/tasks_helper.rb +++ b/app/helpers/maintenance_tasks/tasks_helper.rb @@ -44,12 +44,13 @@ def progress(run) progress = Progress.new(run) - tag.progress( + progress_bar = tag.progress( value: progress.value, max: progress.max, - title: progress.title, class: ["progress"] + STATUS_COLOURS.fetch(run.status) ) + progress_text = tag.p(tag.i(progress.text)) + tag.div(progress_bar + progress_text, class: "block") end # Renders a span with a Run's status, with the corresponding tag class diff --git a/app/models/maintenance_tasks/progress.rb b/app/models/maintenance_tasks/progress.rb index 0b312bb2..11d7c6d1 100644 --- a/app/models/maintenance_tasks/progress.rb +++ b/app/models/maintenance_tasks/progress.rb @@ -4,6 +4,7 @@ module MaintenanceTasks # This class generates progress information about a Run. class Progress include ActiveSupport::NumberHelper + include ActionView::Helpers::TextHelper # Sets the Progress initial state with a Run. # @@ -41,22 +42,23 @@ def max estimatable? ? @run.tick_total : @run.tick_count end - # The title for the progress information. This is a text that describes the - # progress of the Run so far. It includes the percentage that is done out of - # the maximum, if an estimate is possible. + # The text containing progress information. This describes the progress of + # the Run so far. It includes the percentage done out of the maximum, if an + # estimate is possible. # - # @return [String] the title for the Run progress. - def title + # @return [String] the text for the Run progress. + def text + count = @run.tick_count + total = @run.tick_total if !total? - "Processed #{@run.tick_count} #{'item'.pluralize(@run.tick_count)}." + "Processed #{pluralize(count, 'item')}." elsif over_total? - "Processed #{@run.tick_count} #{'item'.pluralize(@run.tick_count)} " \ - "(expected #{@run.tick_total})." + "Processed #{pluralize(count, 'item')} (expected #{total})." else - percentage = 100.0 * @run.tick_count / @run.tick_total + percentage = 100.0 * count / total - "Processed #{@run.tick_count} out of #{@run.tick_total} "\ - "(#{number_to_percentage(percentage, precision: 0)})" + "Processed #{count} out of #{pluralize(total, 'item')} "\ + "(#{number_to_percentage(percentage, precision: 0)})." end end diff --git a/app/views/maintenance_tasks/runs/info/_running.html.erb b/app/views/maintenance_tasks/runs/info/_running.html.erb index 81776c4d..5de17136 100644 --- a/app/views/maintenance_tasks/runs/info/_running.html.erb +++ b/app/views/maintenance_tasks/runs/info/_running.html.erb @@ -1,7 +1,5 @@
<% if run.estimated_completion_time %> <%= estimated_time_to_completion(run).capitalize %> remaining. - <% else %> - Processed <%= pluralize run.tick_count, 'item' %> so far. <% end %>
diff --git a/test/helpers/maintenance_tasks/tasks_helper_test.rb b/test/helpers/maintenance_tasks/tasks_helper_test.rb index 1899d010..bdf983b6 100644 --- a/test/helpers/maintenance_tasks/tasks_helper_test.rb +++ b/test/helpers/maintenance_tasks/tasks_helper_test.rb @@ -20,15 +20,16 @@ class TasksHelperTest < ActionView::TestCase assert_equal expected_trace, format_backtrace(backtrace) end - test "#progress renders a