Display votes in non-anonymous voting results

This commit is contained in:
Brian Wiborg 2024-05-13 12:46:13 +02:00
parent 58cb8645a4
commit f2f8265499
No known key found for this signature in database
GPG key ID: BE53FA9286B719D6
6 changed files with 42 additions and 5 deletions

View file

@ -6,21 +6,24 @@ import (
)
type Vote struct {
Id string
Elector string
Choice Choice
timestamp time.Time
}
func NewVote(elector string, choice Choice) Vote {
func NewVote(id, elector string, choice Choice) Vote {
return Vote{
Id: id,
Elector: elector,
Choice: choice,
timestamp: time.Now().UTC(),
}
}
func NewVoteWithTimestamp(elector string, choice Choice, timestamp time.Time) Vote {
func NewVoteWithTimestamp(id, elector string, choice Choice, timestamp time.Time) Vote {
return Vote{
Id: id,
Elector: elector,
Choice: choice,
timestamp: timestamp,
@ -28,5 +31,5 @@ func NewVoteWithTimestamp(elector string, choice Choice, timestamp time.Time) Vo
}
func (vote Vote) String() string {
return fmt.Sprintf("%s %s %s", vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector)
return fmt.Sprintf("%s %s %s %s", vote.Id, vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector)
}