Use Pleroma.Repo.chunk_stream/2
instead of Pleroma.RepoStreamer.chunk_stream/2
This commit is contained in:
parent
e50314d9d3
commit
a9efd441e2
|
@ -188,18 +188,17 @@ defp write(query, dir, name, fun) do
|
|||
|
||||
with {:ok, file} <- File.open(path, [:write, :utf8]),
|
||||
:ok <- write_header(file, name) do
|
||||
counter = :counters.new(1, [])
|
||||
|
||||
query
|
||||
|> Pleroma.Repo.chunk_stream(100)
|
||||
|> Enum.each(fn i ->
|
||||
with {:ok, str} <- fun.(i),
|
||||
:ok <- IO.write(file, str <> ",\n") do
|
||||
:counters.add(counter, 1, 1)
|
||||
end
|
||||
end)
|
||||
|
||||
total = :counters.get(counter, 1)
|
||||
total =
|
||||
query
|
||||
|> Pleroma.Repo.chunk_stream(100)
|
||||
|> Enum.reduce(0, fn i, acc ->
|
||||
with {:ok, str} <- fun.(i),
|
||||
:ok <- IO.write(file, str <> ",\n") do
|
||||
acc + 1
|
||||
else
|
||||
_ -> acc
|
||||
end
|
||||
end)
|
||||
|
||||
with :ok <- :file.pwrite(file, {:eof, -2}, "\n],\n \"totalItems\": #{total}}") do
|
||||
File.close(file)
|
||||
|
|
Loading…
Reference in a new issue