2019-07-23 13:49:22 +02:00
|
|
|
defmodule MobilizonWeb.Schema.AdminType do
|
|
|
|
@moduledoc """
|
2019-09-22 16:26:23 +02:00
|
|
|
Schema representation for ActionLog.
|
2019-07-23 13:49:22 +02:00
|
|
|
"""
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
use Absinthe.Schema.Notation
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
alias Mobilizon.Events.Event
|
2019-09-22 16:26:23 +02:00
|
|
|
alias Mobilizon.Reports.{Note, Report}
|
|
|
|
|
|
|
|
alias MobilizonWeb.Resolvers.Admin
|
2019-07-23 13:49:22 +02:00
|
|
|
|
|
|
|
@desc "An action log"
|
|
|
|
object :action_log do
|
|
|
|
field(:id, :id, description: "Internal ID for this comment")
|
|
|
|
field(:actor, :actor, description: "The actor that acted")
|
|
|
|
field(:object, :action_log_object, description: "The object that was acted upon")
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:action, :action_log_action, description: "The action that was done")
|
|
|
|
field(:inserted_at, :datetime, description: "The time when the action was performed")
|
|
|
|
end
|
|
|
|
|
|
|
|
enum :action_log_action do
|
|
|
|
value(:report_update_closed)
|
|
|
|
value(:report_update_opened)
|
|
|
|
value(:report_update_resolved)
|
|
|
|
value(:note_creation)
|
|
|
|
value(:note_deletion)
|
|
|
|
value(:event_deletion)
|
|
|
|
value(:event_update)
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The objects that can be in an action log"
|
|
|
|
interface :action_log_object do
|
|
|
|
field(:id, :id, description: "Internal ID for this object")
|
|
|
|
|
|
|
|
resolve_type(fn
|
|
|
|
%Report{}, _ ->
|
|
|
|
:report
|
|
|
|
|
|
|
|
%Note{}, _ ->
|
|
|
|
:report_note
|
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
%Event{}, _ ->
|
|
|
|
:event
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
_, _ ->
|
|
|
|
nil
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
object :dashboard do
|
|
|
|
field(:last_public_event_published, :event, description: "Last public event publish")
|
|
|
|
field(:number_of_users, :integer, description: "The number of local users")
|
|
|
|
field(:number_of_events, :integer, description: "The number of local events")
|
|
|
|
field(:number_of_comments, :integer, description: "The number of local comments")
|
|
|
|
field(:number_of_reports, :integer, description: "The number of current opened reports")
|
|
|
|
end
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
object :admin_queries do
|
|
|
|
@desc "Get the list of action logs"
|
|
|
|
field :action_logs, type: list_of(:action_log) do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Admin.list_action_logs/3)
|
|
|
|
end
|
2019-09-09 09:31:08 +02:00
|
|
|
|
|
|
|
field :dashboard, type: :dashboard do
|
|
|
|
resolve(&Admin.get_dashboard/3)
|
|
|
|
end
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
end
|