fix(coverage): queue compute job after creating a coverage
create flow only inserted the row and left status as :draft, so the worker never ran. Chain queue_compute/1 after create_coverage/2 so the coverage immediately moves to :queued and the show page renders the compute progress.
This commit is contained in:
parent
4191f2dc05
commit
a0d72eee5c
1 changed files with 10 additions and 7 deletions
|
|
@ -131,15 +131,18 @@ defmodule ToweropsWeb.CoverageLive.Form do
|
|||
end
|
||||
|
||||
defp save(socket, :new, attrs) do
|
||||
case Coverages.create_coverage(socket.assigns.organization.id, attrs) do
|
||||
{:ok, coverage} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, t("Coverage created"))
|
||||
|> push_navigate(to: ~p"/coverage/#{coverage.id}")}
|
||||
|
||||
with {:ok, coverage} <- Coverages.create_coverage(socket.assigns.organization.id, attrs),
|
||||
{:ok, queued} <- Coverages.queue_compute(coverage) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, t("Coverage queued for compute"))
|
||||
|> push_navigate(to: ~p"/coverage/#{queued.id}")}
|
||||
else
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply, assign_form(socket, changeset)}
|
||||
|
||||
{:error, _other} ->
|
||||
{:noreply, put_flash(socket, :error, t("Failed to queue coverage compute"))}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue