They already have an index that's good enough.
defp restrict_favorited_by(query, _), do: query
# Only search through last 100_000 activities by default
+ defp restrict_recent(query, %{"whole_db" => true}), do: query
defp restrict_recent(query, _) do
since = (Repo.aggregate(Activity, :max, :id) || 0) - 100_000
params = params
|> Map.put("type", ["Create", "Announce"])
|> Map.put("actor_id", ap_id)
+ |> Map.put("whole_db", true)
activities = ActivityPub.fetch_activities([], params)
|> Enum.reverse
def user_timeline(%{assigns: %{user: user}} = conn, params) do
case TwitterAPI.get_user(user, params) do
{:ok, target_user} ->
- params = Map.merge(params, %{"actor_id" => target_user.ap_id})
+ params = Map.merge(params, %{"actor_id" => target_user.ap_id, "whole_db" => true})
statuses = TwitterAPI.fetch_user_statuses(user, params)
conn
|> json_reply(200, statuses |> Poison.encode!)