- status_query = from p in Activity,
- where: p.local == ^true,
- where: fragment("?->'object'->>'type' = ?", p.data, ^"Note")
- status_count = Repo.aggregate(status_query, :count, :id)
- user_count = Repo.aggregate(User.local_user_query, :count, :id)
- Agent.update(__MODULE__, fn _ ->
- {peers, %{domain_count: domain_count, status_count: status_count, user_count: user_count}}
- end)
+
+ status_count = Repo.aggregate(User.Query.build(%{local: true}), :sum, :note_count)
+
+ user_count = Repo.aggregate(User.Query.build(%{local: true, active: true}), :count, :id)
+
+ %{
+ peers: peers,
+ stats: %{
+ domain_count: domain_count,
+ status_count: status_count,
+ user_count: user_count
+ }
+ }