Skip to content

Commit

Permalink
feat: add order parameter in events controller (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsp45 authored Jan 9, 2024
1 parent b06fd43 commit dfa555b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/bokken/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ defmodule Bokken.Events do
|> Map.fetch!(:events)
end

def list_events(%{"order" => order}) do
query =
if order == "asc",
do: from(e in Event, order_by: [asc: e.start_time]),
else: from(e in Event, order_by: [desc: e.start_time])

Repo.all(query)
|> Repo.preload([:location, :team])
end

def list_events(_args) do
Event
|> Repo.all()
Expand Down

0 comments on commit dfa555b

Please sign in to comment.