def fetch_activities_for_context(context) do
query = from activity in Activity,
- where: fragment("? @> ?", activity.data, ^%{ context: context })
+ where: fragment("? @> ?", activity.data, ^%{ type: "Create", context: context }),
+ order_by: [desc: :inserted_at]
Repo.all(query)
end
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