Skip to content

Commit

Permalink
Backoffice - jobs : support des états "retryable" et "scheduled" (#4342)
Browse files Browse the repository at this point in the history
* Backoffice: affichage des jobs "scheduled"

* Backoffice: affichage des jobs "retryable"
  • Loading branch information
ptitfred authored Nov 27, 2024
1 parent d8249e1 commit faab8a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule TransportWeb.Backoffice.JobsLive do

def last_jobs_query(state, n) do
from(j in "oban_jobs",
select: map(j, [:id, :state, :queue, :worker, :args, :inserted_at, :errors]),
select: map(j, [:id, :state, :queue, :worker, :args, :inserted_at, :scheduled_at, :errors]),
order_by: [desc: j.id],
where: j.state == ^state,
limit: ^n
Expand Down Expand Up @@ -103,8 +103,12 @@ defmodule TransportWeb.Backoffice.JobsLive do
count_completed_jobs: count_jobs("completed", worker_filter),
available_jobs: last_jobs("available", 5, worker_filter),
count_available_jobs: count_jobs("available", worker_filter),
scheduled_jobs: last_jobs("scheduled", 5, worker_filter),
count_scheduled_jobs: count_jobs("scheduled", worker_filter),
last_discarded_jobs: last_jobs("discarded", 5, worker_filter),
count_discarded_jobs: count_jobs("discarded", worker_filter),
retryable_jobs: last_jobs("retryable", 5, worker_filter),
count_retryable_jobs: count_jobs("retryable", worker_filter),
jobs_count: jobs_count(worker_filter)
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<.live_component module={JobsTableComponent} jobs={@last_completed_jobs} state="completed" id="completed_jobs" />
<p class="small">Total: <%= Helpers.format_number(@count_completed_jobs, locale: "en") %></p>

<h2>Scheduled jobs</h2>
<.live_component module={JobsTableComponent} jobs={@scheduled_jobs} state="scheduled" id="scheduled_jobs" />
<p class="small">Total: <%= Helpers.format_number(@count_scheduled_jobs, locale: "en") %></p>

<h2>Retryable jobs</h2>
<.live_component module={JobsTableComponent} jobs={@retryable_jobs} state="retryable" id="retryable_jobs" />
<p class="small">Total: <%= Helpers.format_number(@count_retryable_jobs, locale: "en") %></p>

<h2>Available jobs</h2>
<.live_component module={JobsTableComponent} jobs={@available_jobs} state="available" id="available_jobs" />
<p class="small">Total: <%= Helpers.format_number(@count_available_jobs, locale: "en") %></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ defmodule JobsTableComponent do
<th>worker</th>
<th>args</th>
<th>inserted_at (Paris time)</th>
<%= if @state == "discarded" do %>
<%= if @state in ["discarded", "retryable"] do %>
<th>errors</th>
<% end %>
<%= if @state in ["scheduled", "retryable"] do %>
<th>scheduled_at (Paris time)</th>
<% end %>
</tr>
</thead>
<tbody>
Expand All @@ -29,9 +32,12 @@ defmodule JobsTableComponent do
<td><%= job.worker %></td>
<td><%= inspect(job.args) %></td>
<td><%= format_datetime(job.inserted_at) %></td>
<%= if @state == "discarded" do %>
<%= if @state in ["discarded", "retryable"] do %>
<td><%= inspect(job.errors) %></td>
<% end %>
<%= if @state in ["scheduled", "retryable"] do %>
<td><%= format_datetime(job.scheduled_at) %></td>
<% end %>
</tr>
<% end %>
</tbody>
Expand All @@ -40,6 +46,6 @@ defmodule JobsTableComponent do
end

defp format_datetime(dt) do
Shared.DateTimeDisplay.format_datetime_to_paris(dt, "en", no_timezone: true)
Shared.DateTimeDisplay.format_datetime_to_paris(dt, "en", no_timezone: true, with_seconds: true)
end
end

0 comments on commit faab8a9

Please sign in to comment.