Skip to content

Commit

Permalink
Added sum for getting all tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Oct 13, 2023
1 parent 5efebde commit d0fa82f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/elixir_conf_africa/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ElixirConfAfrica.Events do
alias ElixirConfAfrica.Repo

alias ElixirConfAfrica.Events.Event
alias ElixirConfAfrica.TicketTypes.TicketType

@doc """
Returns the list of events.
Expand All @@ -31,10 +32,14 @@ defmodule ElixirConfAfrica.Events do
end

def get_all_available_tickets do
get_elixir_conf_event_and_ticket_types()
|> Map.get(:ticket_types)
|> Enum.map(fn x -> x.number end)
|> Enum.sum()
get_elixir_conf_event = get_elixir_conf_event()

query =
from t in TicketType,
where: t.event_id == ^get_elixir_conf_event.id,
select: sum(t.number)

Repo.one(query)
end

@doc """
Expand Down

0 comments on commit d0fa82f

Please sign in to comment.