Commit b666f11d authored by lain's avatar lain
Browse files

Add max_id fetching to activity fetching.

parent 6a179a44
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment