-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ability to close a ballot from accepting new votes #109
Draft
zorn
wants to merge
12
commits into
main
Choose a base branch
from
issue-32-add-closed-ballots
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a4ca96
Fix typespecs.
zorn 92229f3
Merge branch 'main' into issue-32-add-closed-ballots
zorn e1b00a8
Add `closed_at` to ballots table and schema. Remove `published_at` fr…
zorn 92e61c1
Fix tests to accommodate new changeset restrictions.
zorn 9ccb8d3
Add new closed ballot fixture for upcoming tests.
zorn f470259
Add restrictions and update error atom for update when trying to upda…
zorn 07e42f9
Introduce `close_ballot/2` and `ballot_status/1` functions.
zorn 4db1f13
Early notes.
zorn 77579fc
Removing validation for field we no longer cast in the general change…
zorn 7f493db
Add tests.
zorn 8586e45
Improve seed data, adding draft and closed ballots.
zorn 8dd3793
Improvements to the admin index page.
zorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
> Users should be able to close a ballot, allowing no more voting. | ||
|
||
Currently we have two states for a ballot. | ||
|
||
published and unpublished | ||
|
||
this is managed by the `:published_at` field which currently can be `nil`. | ||
|
||
Feel like we introduce a `status` field. `unpublished`, `published` and `closed`. | ||
|
||
Remove `published_at` from being in the normal changeset. document and test this. | ||
|
||
Introduce a new function to `close_ballot`. | ||
|
||
Enforce state changes so there can only be one direction. | ||
|
||
Maybe do three diferent `render` templates for the show page depending on status. | ||
|
||
If we don't care about when a ballot was published or closed, it makes the status easier, a simple three value enum. | ||
|
||
If we need to know its status and when the status changed we'd need to save a rich JSON value | ||
|
||
We could also just add `closed_at` and then derive a status with a funcion. | ||
|
||
If feels like the status of a ballot, even in this simple use is starting to outgrow being attached to the ballot directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
priv/repo/migrations/20250101162200_add_closed_at_to_ballots.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Flick.Repo.Migrations.AddClosedAtToBallots do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:ballots) do | ||
add :closed_at, :utc_datetime_usec, null: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be plural if the function accepts a single ballot?