mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Make sure active_user_count/1 counts only local users
This commit is contained in:
parent
13a2ae8ce0
commit
a51d903e0c
2 changed files with 3 additions and 1 deletions
|
@ -2446,7 +2446,7 @@ defmodule Pleroma.User do
|
|||
URI.parse(ap_id).host
|
||||
end
|
||||
|
||||
def update_last_active_at(user) do
|
||||
def update_last_active_at(%__MODULE__{local: true} = user) do
|
||||
user
|
||||
|> cast(%{last_active_at: NaiveDateTime.utc_now()}, [:last_active_at])
|
||||
|> update_and_set_cache()
|
||||
|
@ -2457,6 +2457,7 @@ defmodule Pleroma.User do
|
|||
|
||||
__MODULE__
|
||||
|> where([u], u.last_active_at >= ^active_after)
|
||||
|> where([u], u.local == true)
|
||||
|> Repo.aggregate(:count)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2278,6 +2278,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
test "active_user_count/1" do
|
||||
insert(:user)
|
||||
insert(:user, %{local: false})
|
||||
insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -5)})
|
||||
insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -3)})
|
||||
insert(:user, %{last_active_at: NaiveDateTime.utc_now()})
|
||||
|
|
Loading…
Reference in a new issue