Improve dashboard

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-15 11:04:05 +02:00
parent dacec2672b
commit f6480cb37e
10 changed files with 163 additions and 34 deletions

View File

@@ -798,6 +798,15 @@ defmodule Mobilizon.Events do
@moderator_roles [:moderator, :administrator, :creator]
@doc """
Returns the number of participations for all local events
"""
@spec count_confirmed_participants_for_local_events :: integer()
def count_confirmed_participants_for_local_events do
count_confirmed_participants_for_local_events_query()
|> Repo.one()
end
@doc """
Returns the list of participants for an event.
Default behaviour is to not return :not_approved or :not_confirmed participants
@@ -1548,6 +1557,14 @@ defmodule Mobilizon.Events do
from(s in Session, where: s.track_id == ^track_id)
end
@spec count_confirmed_participants_for_local_events_query :: Ecto.Query.t()
defp count_confirmed_participants_for_local_events_query do
Participant
|> join(:inner, [p], e in Event, on: p.event_id == e.id)
|> where([p, e], e.local and p.role not in [^:not_approved, ^:not_confirmed, ^:rejected])
|> select([p], count(p.id))
end
@spec list_participants_for_event_query(String.t()) :: Ecto.Query.t()
defp list_participants_for_event_query(event_id) do
from(