Show number of participants

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-09-11 16:37:30 +02:00
parent 7bbed59f77
commit c3b03a2e6b
8 changed files with 146 additions and 3 deletions

View File

@@ -747,6 +747,28 @@ defmodule Mobilizon.Events do
|> paginate(page, limit)
end
def count_approved_participants(id) do
query =
from(
p in Participant,
where: p.role != ^:not_approved,
where: p.event_id == ^id
)
Repo.aggregate(query, :count, :id)
end
def count_unapproved_participants(id) do
query =
from(
p in Participant,
where: p.role == ^:not_approved,
where: p.event_id == ^id
)
Repo.aggregate(query, :count, :id)
end
@doc """
Returns the list of participations for an actor.