Skip to content

Commit

Permalink
feat: add order parameter in events controller
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsp45 committed Dec 6, 2023
1 parent b06fd43 commit 23552c3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/bokken/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,19 @@ defmodule Bokken.Events do
|> Map.fetch!(:events)
end

def list_events(%{"order" => order}) do
query = if order == "asc",

Check warning on line 252 in lib/bokken/events.ex

View workflow job for this annotation

GitHub Actions / OTP 25.x / Elixir 1.14.x

There should be no trailing white-space at the end of a line.
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()
query = from e in Event, order_by: [desc: e.start_time]

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

Expand Down

0 comments on commit 23552c3

Please sign in to comment.