add remote user count for the heck of it

This commit is contained in:
FloatingGhost 2022-12-16 17:22:26 +00:00
parent 584f99b69d
commit b91e671c0d
2 changed files with 14 additions and 2 deletions

View file

@ -85,14 +85,24 @@ def calculate_stat_data do
where: not u.invisible where: not u.invisible
) )
remote_users_query =
from(u in User,
where: u.is_active == true,
where: u.local == false,
where: not is_nil(u.nickname),
where: not u.invisible
)
user_count = Repo.aggregate(users_query, :count, :id) user_count = Repo.aggregate(users_query, :count, :id)
remote_user_count = Repo.aggregate(remote_users_query, :count, :id)
%{ %{
peers: peers, peers: peers,
stats: %{ stats: %{
domain_count: domain_count, domain_count: domain_count,
status_count: status_count || 0, status_count: status_count || 0,
user_count: user_count user_count: user_count,
remote_user_count: remote_user_count
} }
} }
end end

View file

@ -109,7 +109,8 @@ defp summary_metrics do
summary("vm.total_run_queue_lengths.io"), summary("vm.total_run_queue_lengths.io"),
last_value("pleroma.local_users.total"), last_value("pleroma.local_users.total"),
last_value("pleroma.domains.total"), last_value("pleroma.domains.total"),
last_value("pleroma.local_statuses.total") last_value("pleroma.local_statuses.total"),
last_value("pleroma.remote_users.total")
] ]
end end
@ -127,5 +128,6 @@ def instance_stats do
:telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{}) :telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{})
:telemetry.execute([:pleroma, :domains], %{total: stats.domain_count}, %{}) :telemetry.execute([:pleroma, :domains], %{total: stats.domain_count}, %{})
:telemetry.execute([:pleroma, :local_statuses], %{total: stats.status_count}, %{}) :telemetry.execute([:pleroma, :local_statuses], %{total: stats.status_count}, %{})
:telemetry.execute([:pleroma, :remote_users], %{total: stats.remote_user_count}, %{})
end end
end end