Make user timelines faster for users with few statuses.
This commit is contained in:
parent
9cda5b897a
commit
5e17e04144
|
@ -112,7 +112,7 @@ defp restrict_max(query, _), do: query
|
|||
|
||||
defp restrict_actor(query, %{"actor_id" => actor_id}) do
|
||||
from activity in query,
|
||||
where: fragment("? @> ?", activity.data, ^%{actor: actor_id})
|
||||
where: fragment("?->>'actor' = ?", activity.data, ^actor_id)
|
||||
end
|
||||
defp restrict_actor(query, _), do: query
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ def feed_redirect(conn, %{"nickname" => nickname}) do
|
|||
def feed(conn, %{"nickname" => nickname}) do
|
||||
user = User.get_cached_by_nickname(nickname)
|
||||
query = from activity in Activity,
|
||||
where: fragment("? @> ?", activity.data, ^%{actor: user.ap_id}),
|
||||
where: fragment("?->>'actor' = ?", activity.data, ^user.ap_id),
|
||||
limit: 20,
|
||||
order_by: [desc: :inserted_at]
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddActorIndexToActivity do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create index(:activities, ["(data->>'actor')", "inserted_at desc"], name: :activities_actor_index)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue