2020-06-19 19:27:10 +02:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.StatisticsType do
|
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Statistics
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Statistics
|
|
|
|
|
|
|
|
@desc "A statistics object"
|
|
|
|
object :statistics do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2020-06-19 19:27:10 +02:00
|
|
|
# Instance name
|
|
|
|
field(:number_of_users, :integer, description: "The number of local users")
|
2020-10-07 10:05:07 +02:00
|
|
|
field(:number_of_events, :integer, description: "The total number of events")
|
|
|
|
field(:number_of_local_events, :integer, description: "The number of local events")
|
|
|
|
field(:number_of_comments, :integer, description: "The total number of comments")
|
|
|
|
field(:number_of_local_comments, :integer, description: "The number of local events")
|
|
|
|
field(:number_of_groups, :integer, description: "The total number of groups")
|
|
|
|
field(:number_of_local_groups, :integer, description: "The number of local groups")
|
|
|
|
|
|
|
|
field(:number_of_instance_followers, :integer,
|
|
|
|
description: "The number of this instance's followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:number_of_instance_followings, :integer,
|
|
|
|
description: "The number of instances this instance follows"
|
|
|
|
)
|
2020-06-19 19:27:10 +02:00
|
|
|
end
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
object :category_statistics do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2022-07-12 10:55:28 +02:00
|
|
|
field(:key, :string, description: "The key for the category")
|
|
|
|
field(:number, :integer, description: "The number of events for the given category")
|
|
|
|
end
|
|
|
|
|
2020-06-19 19:27:10 +02:00
|
|
|
object :statistics_queries do
|
|
|
|
@desc "Get the instance statistics"
|
|
|
|
field :statistics, :statistics do
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
2020-06-19 19:27:10 +02:00
|
|
|
resolve(&Statistics.get_statistics/3)
|
|
|
|
end
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
@desc "Get the instance's category statistics"
|
|
|
|
field :category_statistics, list_of(:category_statistics) do
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
2022-07-12 10:55:28 +02:00
|
|
|
resolve(&Statistics.get_category_statistics/3)
|
|
|
|
end
|
2020-06-19 19:27:10 +02:00
|
|
|
end
|
|
|
|
end
|