Order conversation fetches like GS does.

This commit is contained in:
Roger Braun 2017-06-30 16:30:19 +02:00
parent 6a44427915
commit d4de38e8ff
3 changed files with 5 additions and 4 deletions

View file

@ -77,7 +77,8 @@ def unfollow(follower, followed, local \\ true) do
def fetch_activities_for_context(context) do def fetch_activities_for_context(context) do
query = from activity in Activity, query = from activity in Activity,
where: fragment("? @> ?", activity.data, ^%{ context: context }) where: fragment("? @> ?", activity.data, ^%{ context: context }),
order_by: [desc: :inserted_at]
Repo.all(query) Repo.all(query)
end end

View file

@ -75,7 +75,7 @@ test "retrieves activities that have a given context" do
activities = ActivityPub.fetch_activities_for_context("2hu") activities = ActivityPub.fetch_activities_for_context("2hu")
assert activities == [activity, activity_two] assert activities == [activity_two, activity]
end end
end end

View file

@ -227,8 +227,8 @@ test "fetch statuses in a context using the conversation id" do
statuses = TwitterAPI.fetch_conversation(user, object.id) statuses = TwitterAPI.fetch_conversation(user, object.id)
assert length(statuses) == 2 assert length(statuses) == 2
assert Enum.at(statuses, 0)["id"] == activity.id assert Enum.at(statuses, 1)["id"] == activity.id
assert Enum.at(statuses, 1)["id"] == activity_two.id assert Enum.at(statuses, 0)["id"] == activity_two.id
end end
test "upload a file" do test "upload a file" do