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
|
defmodule MicrowavepropWeb.BackfillLive do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
use MicrowavepropWeb, :live_view
|
use MicrowavepropWeb, :live_view
|
||||||
|
use LiveStash
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
|
|
@ -20,16 +21,22 @@ defmodule MicrowavepropWeb.BackfillLive do
|
||||||
unprocessed = count_unprocessed()
|
unprocessed = count_unprocessed()
|
||||||
total_contacts = Repo.aggregate(from(c in Contact, where: not is_nil(c.pos1)), :count)
|
total_contacts = Repo.aggregate(from(c in Contact, where: not is_nil(c.pos1)), :count)
|
||||||
|
|
||||||
{:ok,
|
case LiveStash.recover_state(socket) do
|
||||||
assign(socket,
|
{:recovered, socket} ->
|
||||||
page_title: "Backfill",
|
{:ok, assign(socket, stats: stats, unprocessed: unprocessed, total_contacts: total_contacts)}
|
||||||
limit: 500,
|
|
||||||
stats: stats,
|
_ ->
|
||||||
unprocessed: unprocessed,
|
{:ok,
|
||||||
total_contacts: total_contacts,
|
assign(socket,
|
||||||
last_enqueued: nil,
|
page_title: "Backfill",
|
||||||
enqueuing: false
|
limit: 500,
|
||||||
)}
|
stats: stats,
|
||||||
|
unprocessed: unprocessed,
|
||||||
|
total_contacts: total_contacts,
|
||||||
|
last_enqueued: nil,
|
||||||
|
enqueuing: false
|
||||||
|
)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
@ -44,7 +51,7 @@ defmodule MicrowavepropWeb.BackfillLive do
|
||||||
send(pid, {:enqueued, count})
|
send(pid, {:enqueued, count})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{:noreply, assign(socket, enqueuing: true)}
|
{:noreply, socket |> assign(enqueuing: true, limit: limit) |> LiveStash.stash_assigns([:limit])}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue