From 1df8658d0d6832e53444ffe4fb1fbddce53e8c95 Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Tue, 10 Dec 2024 16:19:34 +0000 Subject: [PATCH] use aggregate for domain count --- lib/pleroma/stats.ex | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index c47a0f9de..04ea76ca7 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -10,6 +10,7 @@ defmodule Pleroma.Stats do alias Pleroma.CounterCache alias Pleroma.Repo alias Pleroma.User + alias Pleroma.Instance @interval :timer.seconds(300) @@ -64,16 +65,11 @@ defmodule Pleroma.Stats do } } def calculate_stat_data do - peers = + domain_count = from( - u in User, - select: fragment("distinct split_part(?, '@', 2)", u.nickname), - where: u.local != ^true + i in Instance ) - |> Repo.all() - |> Enum.filter(& &1) - - domain_count = Enum.count(peers) + |> Repo.aggregate(:count, :id) status_count = Repo.aggregate(User.Query.build(%{local: true}), :sum, :note_count)