Skip to content

Commit

Permalink
feat(models/poll): update ecto model and derive in preperation for re…
Browse files Browse the repository at this point in the history
…turning json object from vote api route
  • Loading branch information
akinsey committed Jan 9, 2024
1 parent 52d17a1 commit 18b158b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/epochtalk_server/models/poll.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ defmodule EpochtalkServer.Models.Poll do
@derive {Jason.Encoder,
only: [
:thread_id,
:id,
:question,
:locked,
:max_answers,
:expiration,
:change_vote,
:has_voted,
:answers,
:display_mode
]}
schema "polls" do
Expand All @@ -40,6 +43,8 @@ defmodule EpochtalkServer.Models.Poll do
field :expiration, :naive_datetime
field :change_vote, :boolean
field :display_mode, Ecto.Enum, values: [:always, :voted, :expired]
field :has_voted, :boolean, virtual: true
field :answers, {:array, :map}, virtual: true
has_many :poll_answers, PollAnswer
end

Expand Down

0 comments on commit 18b158b

Please sign in to comment.