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()
__MODULE__
|> where([u], u.last_active_at >= ^active_after)
+ |> where([u], u.local == true)
|> Repo.aggregate(:count)
end
end
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()})