fix: flush engine state always

This commit is contained in:
Zach Daniel 2021-07-23 09:45:47 -04:00
parent afc74b7a89
commit b2ae6dc3ea
3 changed files with 10 additions and 11 deletions

View file

@ -65,7 +65,6 @@ Combining them will result in an error on the query.
- Can't go to a specific page number
- Can't use aggregate and calculation sorting
For more information on keyset vs offset based pagination, see:
- [Offset vs Seek Pagination](https://taylorbrazelton.com/posts/2019/03/offset-vs-seek-pagination/)

View file

@ -48,11 +48,16 @@ defmodule Ash.Engine.Runner do
"Synchronous engine starting - #{Enum.map_join(requests, ", ", & &1.name)}"
end)
new_state = run_to_completion(state)
try do
new_state = run_to_completion(state)
new_state.requests
|> Enum.reduce(new_state, &add_data(&2, &1.path, &1.data))
|> Map.put(:resource_notifications, new_state.resource_notifications)
new_state.requests
|> Enum.reduce(new_state, &add_data(&2, &1.path, &1.data))
|> Map.put(:resource_notifications, new_state.resource_notifications)
after
Process.demonitor(state.engine_monitor_ref, [:flush])
flush(state)
end
end
def run_to_completion(state) do
@ -292,10 +297,7 @@ defmodule Ash.Engine.Runner do
end
defp add_engine_state(state, engine_state) do
new_state = %{state | errors: engine_state.errors ++ state.errors}
Process.demonitor(state.engine_monitor_ref, [:flush])
flush(new_state)
%{state | errors: engine_state.errors ++ state.errors}
end
defp build_dependencies(request, dependencies) do

View file

@ -55,8 +55,6 @@ defmodule Ash.Page.Keyset do
else
sort_fields =
sort
# |> Enum.map(fn {key, val} when is_atom(key) ->
# end)
|> Keyword.keys()
|> Enum.sort()