Add max_id fetching to activity fetching.
This commit is contained in:
parent
6a179a44be
commit
b666f11d2f
|
@ -54,6 +54,12 @@ def fetch_activities(recipients, opts \\ %{}) do
|
|||
query = from activity in query,
|
||||
where: activity.id > ^since_id
|
||||
|
||||
query = if opts["max_id"] do
|
||||
from activity in query, where: activity.id < ^opts["max_id"]
|
||||
else
|
||||
query
|
||||
end
|
||||
|
||||
Repo.all(query)
|
||||
|> Enum.reverse
|
||||
end
|
||||
|
|
|
@ -94,6 +94,20 @@ test "retrieves ids starting from a since_id" do
|
|||
assert length(activities) == 10
|
||||
assert last == last_expected
|
||||
end
|
||||
|
||||
test "retrieves ids up to max_id" do
|
||||
_first_activities = ActivityBuilder.insert_list(10)
|
||||
activities = ActivityBuilder.insert_list(20)
|
||||
later_activities = ActivityBuilder.insert_list(10)
|
||||
max_id = List.first(later_activities).id
|
||||
last_expected = List.last(activities)
|
||||
|
||||
activities = ActivityPub.fetch_public_activities(%{"max_id" => max_id})
|
||||
last = List.last(activities)
|
||||
|
||||
assert length(activities) == 20
|
||||
assert last == last_expected
|
||||
end
|
||||
end
|
||||
|
||||
describe "uploading files" do
|
||||
|
|
Loading…
Reference in New Issue