mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2025-01-05 07:12:26 +00:00
use aggregate for domain count
This commit is contained in:
parent
294de939cb
commit
1df8658d0d
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue