2020-06-19 17:27:10 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Resolvers.Statistics do
|
|
|
|
@moduledoc """
|
|
|
|
Handles the statistics-related GraphQL calls.
|
|
|
|
"""
|
|
|
|
|
|
|
|
alias Mobilizon.Service.Statistics, as: StatisticsModule
|
|
|
|
|
|
|
|
@doc """
|
2022-07-12 08:55:28 +00:00
|
|
|
Gets statistics.
|
2020-06-19 17:27:10 +00:00
|
|
|
"""
|
2021-09-28 17:40:37 +00:00
|
|
|
@spec get_statistics(any(), any(), any()) :: {:ok, map()}
|
2020-06-19 17:27:10 +00:00
|
|
|
def get_statistics(_parent, _params, _context) do
|
|
|
|
{:ok,
|
|
|
|
%{
|
|
|
|
number_of_users: StatisticsModule.get_cached_value(:local_users),
|
2020-10-07 08:05:07 +00:00
|
|
|
number_of_events: StatisticsModule.get_cached_value(:federation_events),
|
|
|
|
number_of_local_events: StatisticsModule.get_cached_value(:local_events),
|
|
|
|
number_of_comments: StatisticsModule.get_cached_value(:federation_comments),
|
|
|
|
number_of_local_comments: StatisticsModule.get_cached_value(:local_comments),
|
|
|
|
number_of_groups: StatisticsModule.get_cached_value(:federation_groups),
|
|
|
|
number_of_local_groups: StatisticsModule.get_cached_value(:local_groups),
|
|
|
|
number_of_instance_followings: StatisticsModule.get_cached_value(:instance_followings),
|
|
|
|
number_of_instance_followers: StatisticsModule.get_cached_value(:instance_followers)
|
2020-06-19 17:27:10 +00:00
|
|
|
}}
|
|
|
|
end
|
2022-07-12 08:55:28 +00:00
|
|
|
|
|
|
|
@doc """
|
|
|
|
Gets category statistics
|
|
|
|
"""
|
|
|
|
@spec get_category_statistics(any(), any(), any()) :: {:ok, list()}
|
|
|
|
def get_category_statistics(_parent, _params, _context) do
|
|
|
|
{:ok, StatisticsModule.category_statistics()}
|
|
|
|
end
|
2020-06-19 17:27:10 +00:00
|
|
|
end
|