API can serve bidding_of_highest_round and biddings_of_round/:round_number route.
This commit is contained in:
@ -66,6 +66,26 @@ defmodule BeetRoundServer.Biddings do
|
||||
Repo.get_by!(Bidding, id: id, user_id: scope.user.id)
|
||||
end
|
||||
|
||||
def biddings_of_round(round_number) do
|
||||
Repo.all(
|
||||
from(bidding in Bidding,
|
||||
where: bidding.bidding_round == ^round_number,
|
||||
order_by: [asc: bidding.inserted_at]
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def get_most_recent_bidding(%Scope{} = scope) do
|
||||
query =
|
||||
Ecto.Query.from(bidding in Bidding,
|
||||
where: bidding.user_id == ^scope.user.id,
|
||||
order_by: [desc: bidding.inserted_at],
|
||||
limit: 1
|
||||
)
|
||||
|
||||
Repo.one(query)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Creates a bidding.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user