more accurate user statistics

This commit is contained in:
Luna D 2023-03-28 22:09:24 +02:00
parent 136bfa7eda
commit c38b50aafa
No known key found for this signature in database
GPG key ID: 4B1C63448394F688

View file

@ -86,16 +86,16 @@ defmodule PhilomenaWeb.StatsUpdater do
end
defp users do
first_user = Repo.one(first(User))
last_user = Repo.one(last(User))
time = DateTime.utc_now() |> DateTime.add(-86400, :second)
total =
User
|> Repo.aggregate(:count, :id)
last_24h =
User
|> where([u], u.created_at > ^time)
|> where([u], u.created_at > ago(1, "day"))
|> Repo.aggregate(:count, :id)
{diff(last_user, first_user), last_24h}
{total, last_24h}
end
defp galleries do