From 389e23f1d8bb5eea98cbff4e085df9a729a25f07 Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Wed, 30 Oct 2024 16:11:14 +0100 Subject: [PATCH] Simplify all times shown to not use any words, just exact numbers So everything is hardcoded to English and we don't need to set a locale or having mixed-language phrases all over the place. --- .../mission_control/jobs/dates_helper.rb | 18 ++---------------- .../mission_control/jobs/jobs_helper.rb | 2 +- .../jobs/jobs/_general_information.html.erb | 6 +++--- .../mission_control/jobs/jobs/_job.html.erb | 2 +- .../jobs/jobs/blocked/_job.html.erb | 2 +- .../jobs/jobs/failed/_job.html.erb | 2 +- .../jobs/jobs/finished/_job.html.erb | 2 +- .../jobs/jobs/in_progress/_job.html.erb | 2 +- .../jobs/jobs/scheduled/_job.html.erb | 2 +- .../mission_control/jobs/queues/_job.html.erb | 2 +- .../recurring_tasks/_recurring_task.html.erb | 2 +- .../mission_control/jobs/shared/_job.html.erb | 6 +++--- .../jobs/workers/_worker.html.erb | 2 +- 13 files changed, 18 insertions(+), 32 deletions(-) diff --git a/app/helpers/mission_control/jobs/dates_helper.rb b/app/helpers/mission_control/jobs/dates_helper.rb index cc8bc020..70d7cf93 100644 --- a/app/helpers/mission_control/jobs/dates_helper.rb +++ b/app/helpers/mission_control/jobs/dates_helper.rb @@ -1,19 +1,5 @@ module MissionControl::Jobs::DatesHelper - def time_ago_in_words_with_title(time) - tag.span time_ago_in_words(time), title: time.to_fs(:long) - end - - def time_distance_in_words_with_title(time) - tag.span distance_of_time_in_words_to_now(time, include_seconds: true), title: "Since #{time.to_fs(:long)}" - end - - def bidirectional_time_distance_in_words_with_title(time) - time_distance = if time.past? - "#{distance_of_time_in_words_to_now(time, include_seconds: true)} ago" - else - "in #{distance_of_time_in_words_to_now(time, include_seconds: true)}" - end - - tag.span time_distance, title: time.to_fs(:long) + def formatted_time(time) + time.strftime("%Y-%m-%d %H:%M:%S.%3N") end end diff --git a/app/helpers/mission_control/jobs/jobs_helper.rb b/app/helpers/mission_control/jobs/jobs_helper.rb index 14219e6c..b37e0b52 100644 --- a/app/helpers/mission_control/jobs/jobs_helper.rb +++ b/app/helpers/mission_control/jobs/jobs_helper.rb @@ -29,7 +29,7 @@ def attribute_names_for_job_status(status) when "blocked" then [ "Queue", "Blocked by", "Block expiry", "" ] when "finished" then [ "Queue", "Finished" ] when "scheduled" then [ "Queue", "Scheduled", "" ] - when "in_progress" then [ "Queue", "Run by", "Running for" ] + when "in_progress" then [ "Queue", "Run by", "Running since" ] else [] end end diff --git a/app/views/mission_control/jobs/jobs/_general_information.html.erb b/app/views/mission_control/jobs/jobs/_general_information.html.erb index dbd20882..0030facd 100644 --- a/app/views/mission_control/jobs/jobs/_general_information.html.erb +++ b/app/views/mission_control/jobs/jobs/_general_information.html.erb @@ -23,14 +23,14 @@ Enqueued - <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago + <%= formatted_time(job.enqueued_at.to_datetime) %> <% if job.failed? %> Failed - <%= time_ago_in_words_with_title(job.failed_at) %> ago + <%= formatted_time(job.failed_at) %> <% end %> @@ -38,7 +38,7 @@ Finished at - <%= time_ago_in_words_with_title(job.finished_at) %> ago + <%= formatted_time(job.finished_at) %> <% end %> diff --git a/app/views/mission_control/jobs/jobs/_job.html.erb b/app/views/mission_control/jobs/jobs/_job.html.erb index 881eaba6..bdf8ba54 100644 --- a/app/views/mission_control/jobs/jobs/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/_job.html.erb @@ -6,7 +6,7 @@
<%= job_arguments(job) %>
<% end %> -
Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago
+
Enqueued <%= formatted_time(job.enqueued_at.to_datetime) %>
<%= render "mission_control/jobs/jobs/#{jobs_status}/job", job: job %> diff --git a/app/views/mission_control/jobs/jobs/blocked/_job.html.erb b/app/views/mission_control/jobs/jobs/blocked/_job.html.erb index 8135c73f..5b79386b 100644 --- a/app/views/mission_control/jobs/jobs/blocked/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/blocked/_job.html.erb @@ -1,6 +1,6 @@ <%= link_to job.queue_name, application_queue_path(@application, job.queue) %>
<%= job.blocked_by %>
-<%= bidirectional_time_distance_in_words_with_title(job.blocked_until) %> +<%= formatted_time(job.blocked_until) %> <%= render "mission_control/jobs/jobs/blocked/actions", job: job %> diff --git a/app/views/mission_control/jobs/jobs/failed/_job.html.erb b/app/views/mission_control/jobs/jobs/failed/_job.html.erb index 54f39510..5291336c 100644 --- a/app/views/mission_control/jobs/jobs/failed/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/failed/_job.html.erb @@ -1,6 +1,6 @@ <%= link_to failed_job_error(job), application_job_path(@application, job.job_id, anchor: "error") %> -
<%= time_ago_in_words_with_title(job.failed_at) %> ago
+
<%= formatted_time(job.failed_at) %>
<%= render "mission_control/jobs/jobs/failed/actions", job: job %> diff --git a/app/views/mission_control/jobs/jobs/finished/_job.html.erb b/app/views/mission_control/jobs/jobs/finished/_job.html.erb index 3a6b7cfc..b0e9f201 100644 --- a/app/views/mission_control/jobs/jobs/finished/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/finished/_job.html.erb @@ -1,2 +1,2 @@ <%= link_to job.queue_name, application_queue_path(@application, job.queue) %> -
<%= time_ago_in_words_with_title(job.finished_at) %> ago
+
<%= formatted_time(job.finished_at) %>
diff --git a/app/views/mission_control/jobs/jobs/in_progress/_job.html.erb b/app/views/mission_control/jobs/jobs/in_progress/_job.html.erb index 48491725..f428b28f 100644 --- a/app/views/mission_control/jobs/jobs/in_progress/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/in_progress/_job.html.erb @@ -6,4 +6,4 @@ — <% end %> -
<%= job.started_at ? time_distance_in_words_with_title(job.started_at) : "(Finished)" %>
+
<%= job.started_at ? formatted_time(job.started_at) : "(Finished)" %>
diff --git a/app/views/mission_control/jobs/jobs/scheduled/_job.html.erb b/app/views/mission_control/jobs/jobs/scheduled/_job.html.erb index 78b5a366..b337a04e 100644 --- a/app/views/mission_control/jobs/jobs/scheduled/_job.html.erb +++ b/app/views/mission_control/jobs/jobs/scheduled/_job.html.erb @@ -1,6 +1,6 @@ <%= link_to job.queue_name, application_queue_path(@application, job.queue) %> - <%= bidirectional_time_distance_in_words_with_title(job.scheduled_at) %> + <%= formatted_time(job.scheduled_at) %> <% if job_delayed?(job) %>
delayed
<% end %> diff --git a/app/views/mission_control/jobs/queues/_job.html.erb b/app/views/mission_control/jobs/queues/_job.html.erb index 36cd2c7b..34c0ae8e 100644 --- a/app/views/mission_control/jobs/queues/_job.html.erb +++ b/app/views/mission_control/jobs/queues/_job.html.erb @@ -3,7 +3,7 @@ <%= link_to application_job_path(@application, job.job_id, filter: { queue_name: job.queue }) do %> <%= job_title(job) %> <% end %> -
Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago
+
Enqueued on <%= formatted_time(job.enqueued_at.to_datetime) %>
<% if job.serialized_arguments.present? %> diff --git a/app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb b/app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb index c7d3204b..a890da60 100644 --- a/app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb +++ b/app/views/mission_control/jobs/recurring_tasks/_recurring_task.html.erb @@ -14,5 +14,5 @@ <% end %> <%= recurring_task.schedule %> -
<%= recurring_task.last_enqueued_at ? bidirectional_time_distance_in_words_with_title(recurring_task.last_enqueued_at) : "Never" %>
+
<%= recurring_task.last_enqueued_at ? formatted_time(recurring_task.last_enqueued_at) : "Never" %>
diff --git a/app/views/mission_control/jobs/shared/_job.html.erb b/app/views/mission_control/jobs/shared/_job.html.erb index 22780568..52075dba 100644 --- a/app/views/mission_control/jobs/shared/_job.html.erb +++ b/app/views/mission_control/jobs/shared/_job.html.erb @@ -3,7 +3,7 @@ <%= link_to application_job_path(@application, job.job_id, filter: { queue_name: job.queue }) do %> <%= job_title(job) %> <% end %> -
Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago
+
Enqueued on <%= formatted_time(job.enqueued_at.to_datetime) %>
<% if job.serialized_arguments.present? %> @@ -16,9 +16,9 @@
<% if job.started_at %> - Running for <%= time_distance_in_words_with_title(job.started_at) %> + Running since <%= formatted_time(job.started_at) %> <% elsif job.finished_at %> - Finished <%= time_ago_in_words_with_title(job.finished_at) %> ago + Finished on <%= formatted_time(job.finished_at) %> <% else %> Pending <% end %> diff --git a/app/views/mission_control/jobs/workers/_worker.html.erb b/app/views/mission_control/jobs/workers/_worker.html.erb index be9eaadf..a10a3d07 100644 --- a/app/views/mission_control/jobs/workers/_worker.html.erb +++ b/app/views/mission_control/jobs/workers/_worker.html.erb @@ -17,5 +17,5 @@ <% end %> -
<%= time_ago_in_words_with_title(worker.last_heartbeat_at) %> ago
+
<%= formatted_time(worker.last_heartbeat_at) %>