Skip to content

Commit

Permalink
Simplify all times shown to not use any words, just exact numbers
Browse files Browse the repository at this point in the history
So everything is hardcoded to English and we don't need to set a locale
or having mixed-language phrases all over the place.
  • Loading branch information
rosa committed Oct 30, 2024
1 parent 75f64ee commit 389e23f
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 32 deletions.
18 changes: 2 additions & 16 deletions app/helpers/mission_control/jobs/dates_helper.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/helpers/mission_control/jobs/jobs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
<tr>
<th>Enqueued</th>
<td>
<%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago
<%= formatted_time(job.enqueued_at.to_datetime) %>
</td>
</tr>
<% if job.failed? %>
<tr>
<th>Failed</th>
<td>
<%= time_ago_in_words_with_title(job.failed_at) %> ago
<%= formatted_time(job.failed_at) %>
</td>
</tr>
<% end %>
<% if job.finished_at.present? %>
<tr>
<th>Finished at</th>
<td>
<%= time_ago_in_words_with_title(job.finished_at) %> ago
<%= formatted_time(job.finished_at) %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/jobs/_job.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="is-family-monospace"><%= job_arguments(job) %></div>
<% end %>

<div class="has-text-grey is-size-7">Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago</div>
<div class="has-text-grey is-size-7">Enqueued <%= formatted_time(job.enqueued_at.to_datetime) %></div>
</td>

<%= render "mission_control/jobs/jobs/#{jobs_status}/job", job: job %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/jobs/blocked/_job.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
<td><div class="is-family-monospace is-size-7"><%= job.blocked_by %></div></td>
<td><%= bidirectional_time_distance_in_words_with_title(job.blocked_until) %></td>
<td><%= formatted_time(job.blocked_until) %></td>
<td class="pr-0">
<%= render "mission_control/jobs/jobs/blocked/actions", job: job %>
</td>
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/jobs/failed/_job.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<td>
<%= link_to failed_job_error(job), application_job_path(@application, job.job_id, anchor: "error") %>
<div class="has-text-grey"><%= time_ago_in_words_with_title(job.failed_at) %> ago</div>
<div class="has-text-grey"><%= formatted_time(job.failed_at) %></div>
</td>
<td class="pr-0">
<%= render "mission_control/jobs/jobs/failed/actions", job: job %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/jobs/finished/_job.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
<td><div class="has-text-grey"><%= time_ago_in_words_with_title(job.finished_at) %> ago</div></td>
<td><div class="has-text-grey"><%= formatted_time(job.finished_at) %></div></td>
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
<% end %>
</td>
<td><div class="has-text-grey"><%= job.started_at ? time_distance_in_words_with_title(job.started_at) : "(Finished)" %></div></td>
<td><div class="has-text-grey"><%= job.started_at ? formatted_time(job.started_at) : "(Finished)" %></div></td>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
<td>
<%= bidirectional_time_distance_in_words_with_title(job.scheduled_at) %>
<%= formatted_time(job.scheduled_at) %>
<% if job_delayed?(job) %>
<div class="is-danger tag ml-4">delayed</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/queues/_job.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= link_to application_job_path(@application, job.job_id, filter: { queue_name: job.queue }) do %>
<%= job_title(job) %>
<% end %>
<div class="has-text-grey">Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago</div>
<div class="has-text-grey">Enqueued on <%= formatted_time(job.enqueued_at.to_datetime) %></div>
</td>
<td>
<% if job.serialized_arguments.present? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
<% end %>
</td>
<td> <%= recurring_task.schedule %> </td>
<td><div class="has-text-grey"><%= recurring_task.last_enqueued_at ? bidirectional_time_distance_in_words_with_title(recurring_task.last_enqueued_at) : "Never" %></div></td>
<td><div class="has-text-grey"><%= recurring_task.last_enqueued_at ? formatted_time(recurring_task.last_enqueued_at) : "Never" %></div></td>
</tr>
6 changes: 3 additions & 3 deletions app/views/mission_control/jobs/shared/_job.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= link_to application_job_path(@application, job.job_id, filter: { queue_name: job.queue }) do %>
<%= job_title(job) %>
<% end %>
<div class="has-text-grey">Enqueued <%= time_ago_in_words_with_title(job.enqueued_at.to_datetime) %> ago</div>
<div class="has-text-grey">Enqueued on <%= formatted_time(job.enqueued_at.to_datetime) %></div>
</td>
<td>
<% if job.serialized_arguments.present? %>
Expand All @@ -16,9 +16,9 @@
<td>
<div class="has-text-grey">
<% 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 %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/workers/_worker.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
<% end %>
</td>

<td><div class="has-text-grey"><%= time_ago_in_words_with_title(worker.last_heartbeat_at) %> ago</div></td>
<td><div class="has-text-grey"><%= formatted_time(worker.last_heartbeat_at) %></div></td>
</tr>

0 comments on commit 389e23f

Please sign in to comment.