diff options
| author | Paul Buetow <paul@buetow.org> | 2023-11-04 15:28:16 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-11-04 15:28:16 +0200 |
| commit | 314aa39afda105969567c4f95b07147f372fcf98 (patch) | |
| tree | 62ead034a09bb328e3995da887d29e8cdfe69b00 | |
| parent | 09ecd479863cf5db5b91776b64324660e23eeb97 (diff) | |
move Score to its own file
| -rw-r--r-- | internal/quorum/quorum.go | 21 | ||||
| -rw-r--r-- | internal/quorum/score.go | 26 |
2 files changed, 27 insertions, 20 deletions
diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go index 9bce233..71954f4 100644 --- a/internal/quorum/quorum.go +++ b/internal/quorum/quorum.go @@ -24,25 +24,6 @@ type Quorum struct { votes map[string]vote.Vote } -type Score struct { - ID string - Value int -} - -func (s Score) Is(other Score) bool { - return s.ID == other.ID && s.Value == other.Value -} - -type Scores []Score - -func (s Scores) Winner() (Score, error) { - if len(s) == 0 { - return Score{}, fmt.Errorf("emtpy score, no winner") - } - - return s[0], nil -} - func New(conf config.Config) Quorum { return Quorum{ conf: conf, @@ -124,7 +105,7 @@ func (quo Quorum) scores() (scores Scores) { } for id, score_ := range scoreMap { - scores = append(scores, Score{id, score_}) + scores = append(scores, Score{id, score_, time.Now()}) } sort.Slice(scores, func(i, j int) bool { diff --git a/internal/quorum/score.go b/internal/quorum/score.go new file mode 100644 index 0000000..d67b791 --- /dev/null +++ b/internal/quorum/score.go @@ -0,0 +1,26 @@ +package quorum + +import ( + "fmt" + "time" +) + +type Score struct { + ID string + Value int + time time.Time +} + +func (s Score) Is(other Score) bool { + return s.ID == other.ID && s.Value == other.Value +} + +type Scores []Score + +func (s Scores) Winner() (Score, error) { + if len(s) == 0 { + return Score{}, fmt.Errorf("emtpy score, no winner") + } + + return s[0], nil +} |
