diff options
author | kaniini <nenolod@gmail.com> | 2019-01-17 19:27:15 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2019-01-17 19:27:15 +0000 |
commit | 98d9dcd509ab6823e38b3ddbce1f5fc4f3d5a82c (patch) | |
tree | 5731bd6ab614b347224fe527744279c4f4c673f3 /lib | |
parent | ae8a5942cf4da8a6046f5105ab9044f9faa164d6 (diff) | |
parent | 954dc4a4ad8a387ca7b18bb7d0ed32456491daec (diff) | |
download | pleroma-98d9dcd509ab6823e38b3ddbce1f5fc4f3d5a82c.tar.gz |
Merge branch '502_instance_stats_active_users_count_fix' into 'develop'
[#502] Fixed `user_count` in `/api/v1/instance` to include only active local users
Closes #502
See merge request pleroma/pleroma!678
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/stats.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/user.ex | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index 65a6d58b5..b3566ceb6 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -46,7 +46,7 @@ defmodule Pleroma.Stats do from(u in User.local_user_query(), select: fragment("sum((?->>'note_count')::int)", u.info)) status_count = Repo.one(status_query) - user_count = Repo.aggregate(User.local_user_query(), :count, :id) + user_count = Repo.aggregate(User.active_local_user_query(), :count, :id) Agent.update(__MODULE__, fn _ -> {peers, %{domain_count: domain_count, status_count: status_count, user_count: user_count}} diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index a52e536d3..c91f2d31a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -796,7 +796,7 @@ defmodule Pleroma.User do update_and_set_cache(cng) end - def local_user_query() do + def local_user_query do from( u in User, where: u.local == true, @@ -804,7 +804,14 @@ defmodule Pleroma.User do ) end - def moderator_user_query() do + def active_local_user_query do + from( + u in local_user_query(), + where: fragment("?->'deactivated' @> 'false'", u.info) + ) + end + + def moderator_user_query do from( u in User, where: u.local == true, |