Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7893108
repo_streamer.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
746 B
Referenced Files
None
Subscribers
None
repo_streamer.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.RepoStreamer
do
alias
Pleroma.Repo
import
Ecto.Query
def
chunk_stream
(
query
,
chunk_size
)
do
Stream
.
unfold
(
0
,
fn
:halt
->
{[],
:halt
}
last_id
->
query
|>
order_by
(
asc
:
:id
)
|>
where
([
r
],
r
.
id
>
^
last_id
)
|>
limit
(
^
chunk_size
)
|>
Repo
.
all
()
|>
case
do
[]
->
{[],
:halt
}
records
->
last_id
=
List
.
last
(
records
)
.
id
{
records
,
last_id
}
end
end
)
|>
Stream
.
take_while
(
fn
[]
->
false
_
->
true
end
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Thu, Oct 2, 4:48 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
480255
Default Alt Text
repo_streamer.ex (746 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment