Skip to content

Commit

Permalink
Store is_low only if the value has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kozaktomas committed Nov 2, 2024
1 parent 4ed24e8 commit ed5d9a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/pkg/scale/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ func (s *Scale) AddMeasurement(weight float64) error {
// check if keg is low
if !s.isLow {
s.isLow = IsKegLow(s.activeKeg, weight)
if serr := s.store.SetIsLow(s.isLow); serr != nil {
return fmt.Errorf("could not store is_low: %w", serr)
if s.isLow {
if serr := s.store.SetIsLow(s.isLow); serr != nil {
return fmt.Errorf("could not store is_low: %w", serr)
}
}
}

Expand Down

0 comments on commit ed5d9a3

Please sign in to comment.