summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-11-04 15:28:16 +0200
committerPaul Buetow <paul@buetow.org>2023-11-04 15:28:16 +0200
commit314aa39afda105969567c4f95b07147f372fcf98 (patch)
tree62ead034a09bb328e3995da887d29e8cdfe69b00
parent09ecd479863cf5db5b91776b64324660e23eeb97 (diff)
move Score to its own file
-rw-r--r--internal/quorum/quorum.go21
-rw-r--r--internal/quorum/score.go26
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
+}