Sorted performer and performance queries.

This commit is contained in:
codevictory
2021-04-28 21:30:23 +03:00
parent 607ae59589
commit 449bb999ff
4 changed files with 28 additions and 2 deletions

View File

@@ -21,6 +21,19 @@ defmodule Runosaari.Registration do
Repo.all(Performer) Repo.all(Performer)
end end
@doc """
Returns the list of performers.
## Examples
iex> list_performers()
[%Performer{}, ...]
"""
def list_sorted_performers do
Repo.all(Performer |> order_by(:seqnum))
end
@doc """ @doc """
Gets a single performer. Gets a single performer.

View File

@@ -21,6 +21,19 @@ defmodule Runosaari.Schedule do
Repo.all(Performance) Repo.all(Performance)
end end
@doc """
Returns the list of performances sorted by seqnum.
## Examples
iex> list_sorted_performances()
[%Performance{}, ...]
"""
def list_sorted_performances do
Repo.all(Performance |> order_by(:seqnum))
end
@doc """ @doc """
Gets a single performance. Gets a single performance.

View File

@@ -5,7 +5,7 @@ defmodule RunosaariWeb.PerformanceController do
alias Runosaari.Schedule.Performance alias Runosaari.Schedule.Performance
def index(conn, _params) do def index(conn, _params) do
performances = Schedule.list_performances() performances = Schedule.list_sorted_performances()
render(conn, "index.html", performances: performances) render(conn, "index.html", performances: performances)
end end

View File

@@ -5,7 +5,7 @@ defmodule RunosaariWeb.PerformerController do
alias Runosaari.Registration.Performer alias Runosaari.Registration.Performer
def index(conn, _params) do def index(conn, _params) do
performers = Registration.list_performers() performers = Registration.list_sorted_performers()
render(conn, "index.html", performers: performers) render(conn, "index.html", performers: performers)
end end