add remote user count for the heck of it
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 16 Dec 2022 17:22:26 +0000 (17:22 +0000)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Fri, 16 Dec 2022 17:22:26 +0000 (17:22 +0000)
lib/pleroma/stats.ex
lib/pleroma/web/telemetry.ex

index 3e3f24c2c21cae836bd7831c5c4b59d04c7dff51..cda1fb9a65ddb744ff9e0e705fc264b81ab4ea69 100644 (file)
@@ -85,14 +85,24 @@ defmodule Pleroma.Stats do
         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)
+    remote_user_count = Repo.aggregate(remote_users_query, :count, :id)
 
     %{
       peers: peers,
       stats: %{
         domain_count: domain_count,
         status_count: status_count || 0,
-        user_count: user_count
+        user_count: user_count,
+        remote_user_count: remote_user_count
       }
     }
   end
index 5b01ee14deeb97218b0ea168c78f90153c1a736e..acb649421a8a8a217bd58eb2681dbd5607fc46f9 100644 (file)
@@ -109,7 +109,8 @@ defmodule Pleroma.Web.Telemetry do
       summary("vm.total_run_queue_lengths.io"),
       last_value("pleroma.local_users.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
 
@@ -127,5 +128,6 @@ defmodule Pleroma.Web.Telemetry do
     :telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{})
     :telemetry.execute([:pleroma, :domains], %{total: stats.domain_count}, %{})
     :telemetry.execute([:pleroma, :local_statuses], %{total: stats.status_count}, %{})
+    :telemetry.execute([:pleroma, :remote_users], %{total: stats.remote_user_count}, %{})
   end
 end