Expose more statistics

* differenciate local & all events/comments/groups
* add instance follows/followings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-07 10:05:07 +02:00
parent 09a0cbf3f1
commit 02eac30c9b
8 changed files with 118 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ defmodule Mobilizon.Service.Statistics do
"""
alias Mobilizon.{Actors, Discussions, Events, Users}
alias Mobilizon.Federation.ActivityPub.Relay
def get_cached_value(key) do
case Cachex.fetch(:statistics, key, fn key ->
@@ -44,4 +45,14 @@ defmodule Mobilizon.Service.Statistics do
defp create_cache(:federation_groups) do
Actors.count_groups()
end
defp create_cache(:instance_followers) do
relay_actor = Relay.get_actor()
Actors.count_followers_for_actor(relay_actor)
end
defp create_cache(:instance_followings) do
relay_actor = Relay.get_actor()
Actors.count_followings_for_actor(relay_actor)
end
end