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 end
defp users do defp users do
first_user = Repo.one(first(User)) total =
last_user = Repo.one(last(User)) User
time = DateTime.utc_now() |> DateTime.add(-86400, :second) |> Repo.aggregate(:count, :id)
last_24h = last_24h =
User User
|> where([u], u.created_at > ^time) |> where([u], u.created_at > ago(1, "day"))
|> Repo.aggregate(:count, :id) |> Repo.aggregate(:count, :id)
{diff(last_user, first_user), last_24h} {total, last_24h}
end end
defp galleries do defp galleries do