Add LiveStash to backfill page, recover limit on reconnect
This commit is contained in:
parent
c1da0f20b1
commit
59665a5009
1 changed files with 18 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
defmodule MicrowavepropWeb.BackfillLive do
|
||||
@moduledoc false
|
||||
use MicrowavepropWeb, :live_view
|
||||
use LiveStash
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
|
|
@ -20,16 +21,22 @@ defmodule MicrowavepropWeb.BackfillLive do
|
|||
unprocessed = count_unprocessed()
|
||||
total_contacts = Repo.aggregate(from(c in Contact, where: not is_nil(c.pos1)), :count)
|
||||
|
||||
{:ok,
|
||||
assign(socket,
|
||||
page_title: "Backfill",
|
||||
limit: 500,
|
||||
stats: stats,
|
||||
unprocessed: unprocessed,
|
||||
total_contacts: total_contacts,
|
||||
last_enqueued: nil,
|
||||
enqueuing: false
|
||||
)}
|
||||
case LiveStash.recover_state(socket) do
|
||||
{:recovered, socket} ->
|
||||
{:ok, assign(socket, stats: stats, unprocessed: unprocessed, total_contacts: total_contacts)}
|
||||
|
||||
_ ->
|
||||
{:ok,
|
||||
assign(socket,
|
||||
page_title: "Backfill",
|
||||
limit: 500,
|
||||
stats: stats,
|
||||
unprocessed: unprocessed,
|
||||
total_contacts: total_contacts,
|
||||
last_enqueued: nil,
|
||||
enqueuing: false
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
@ -44,7 +51,7 @@ defmodule MicrowavepropWeb.BackfillLive do
|
|||
send(pid, {:enqueued, count})
|
||||
end)
|
||||
|
||||
{:noreply, assign(socket, enqueuing: true)}
|
||||
{:noreply, socket |> assign(enqueuing: true, limit: limit) |> LiveStash.stash_assigns([:limit])}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue