Skip to content

Commit

Permalink
Chore: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mindreframer committed Aug 24, 2024
1 parent 163c3b6 commit a1e90ad
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/casts/db_feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ defmodule Essig.Casts.DbFeed do
use Essig.Repo

def hydrate_cast(module) do
scope_uuid = Essig.Context.current_scope()

query =
from e in Essig.Schemas.Event, where: e.scope_uuid == ^scope_uuid, order_by: [asc: :id]

stream = query |> Repo.cursor_based_stream(max_rows: 100)

stream = scoped_events() |> Repo.cursor_based_stream(max_rows: 100)
Essig.Casts.CastRunner.send_events(module, stream)

Enum.reduce(stream, %{}, fn _event, _acc ->
Expand All @@ -17,4 +11,9 @@ defmodule Essig.Casts.DbFeed do
# %TestReportProcess{entity | seq: event.seq}
end)
end

def scoped_events do
scope_uuid = Essig.Context.current_scope()
from e in Essig.Schemas.Event, where: e.scope_uuid == ^scope_uuid, order_by: [asc: :id]
end
end

0 comments on commit a1e90ad

Please sign in to comment.