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

@@ -1076,6 +1076,17 @@ defmodule Mobilizon.Actors do
|> Page.build_page(page, limit)
end
@doc """
Returns the number of followers for an actor
"""
@spec count_followers_for_actor(Actor.t()) :: integer()
def count_followers_for_actor(%Actor{id: actor_id}) do
actor_id
|> follower_for_actor_query()
|> where(approved: true)
|> Repo.aggregate(:count)
end
@doc """
Returns the list of followings for an actor.
If actor A follows actor B and C, actor A's followings are B and C.
@@ -1087,6 +1098,17 @@ defmodule Mobilizon.Actors do
|> Repo.all()
end
@doc """
Returns the number of followings for an actor
"""
@spec count_followings_for_actor(Actor.t()) :: integer()
def count_followings_for_actor(%Actor{id: actor_id}) do
actor_id
|> followings_for_actor_query()
|> where(approved: true)
|> Repo.aggregate(:count)
end
@doc """
Returns the list of external followings for an actor.
"""