forked from AkkomaGang/akkoma
Use desc id to sort instead of desc inserted_at
Should mean the same and is indexed.
This commit is contained in:
parent
003cb17b16
commit
678dd4c8ec
3 changed files with 3 additions and 3 deletions
|
@ -97,7 +97,7 @@ def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ tru
|
||||||
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("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
where: fragment("?->>'type' = ? and ?->>'context' = ?", activity.data, "Create", activity.data, ^context),
|
||||||
order_by: [desc: :inserted_at]
|
order_by: [desc: :id]
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ def fetch_latest_follow(%User{ap_id: follower_id},
|
||||||
query = from activity in Activity,
|
query = from activity in Activity,
|
||||||
where: fragment("? @> ?", activity.data, ^%{type: "Follow", actor: follower_id,
|
where: fragment("? @> ?", activity.data, ^%{type: "Follow", actor: follower_id,
|
||||||
object: followed_id}),
|
object: followed_id}),
|
||||||
order_by: [desc: :inserted_at],
|
order_by: [desc: :id],
|
||||||
limit: 1
|
limit: 1
|
||||||
Repo.one(query)
|
Repo.one(query)
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ def feed(conn, %{"nickname" => nickname}) do
|
||||||
query = from activity in Activity,
|
query = from activity in Activity,
|
||||||
where: fragment("?->>'actor' = ?", activity.data, ^user.ap_id),
|
where: fragment("?->>'actor' = ?", activity.data, ^user.ap_id),
|
||||||
limit: 20,
|
limit: 20,
|
||||||
order_by: [desc: :inserted_at]
|
order_by: [desc: :id]
|
||||||
|
|
||||||
activities = query
|
activities = query
|
||||||
|> Repo.all
|
|> Repo.all
|
||||||
|
|
Loading…
Reference in a new issue