Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
zorn committed Aug 14, 2024
1 parent 480adea commit edbb8c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/flick/ranked_voting.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ defmodule Flick.RankedVoting do
|> Repo.insert()
end

@doc """
Updates the given `Flick.RankedVoting.Vote` entity with the given attributes.
The `:weight` field is the only expected edited value.
If the given `Flick.RankedVoting.Ballot` does not align with the `ballot_id`
of the `Flick.RankedVoting.Vote`, then the function will not match.
"""
@spec update_vote(Ballot.t(), Vote.t(), map()) ::
{:ok, Vote.t()} | {:error, Ecto.Changeset.t(Vote.t())}
def update_vote(%Ballot{id: id}, %Vote{ballot_id: ballot_id} = vote, attrs)
Expand Down Expand Up @@ -182,6 +190,11 @@ defmodule Flick.RankedVoting do
end
end

@doc """
Returns a list of `Flick.RankedVoting.Vote` entities associated with the given
`ballot_id`.
"""
@spec list_votes_for_ballot_id(Ballot.id()) :: [Vote.t()]
def list_votes_for_ballot_id(ballot_id) do
Vote
|> where(ballot_id: ^ballot_id)
Expand Down

0 comments on commit edbb8c8

Please sign in to comment.