Skip to content

Commit

Permalink
Add sorting for backdated doses
Browse files Browse the repository at this point in the history
  • Loading branch information
VanuPhantom committed Feb 6, 2024
1 parent 028d899 commit 9e38bcb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion logic/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package logic
import (
"log"
"os"
"sort"
"time"
)

Expand Down Expand Up @@ -41,6 +42,14 @@ func Load() ([]Dose, error) {

raw := string(bytes)

return decode(raw)
if doses, err := decode(raw); err != nil {
return nil, err
} else {
sort.Slice(doses, func(i, j int) bool {
return doses[i].Time.Unix() < doses[j].Time.Unix()
})

return doses, nil
}
}
}

0 comments on commit 9e38bcb

Please sign in to comment.