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:
Graham McIntire 2026-05-06 15:49:18 -05:00
parent 4191f2dc05
commit a0d72eee5c

View file

@ -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