Skip to content

Commit

Permalink
Tariff: support >48 slots
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 23, 2024
1 parent 7665094 commit fc37713
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tariff/tariff.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,17 @@ func (t *Tariff) priceRates() (api.Rates, error) {
return nil, err
}

res := make(api.Rates, 48)
res := make(api.Rates, 0, 48)
start := now.BeginningOfHour()

for i := 0; i < len(res); i++ {
slot := start.Add(time.Duration(i) * time.Hour)
res[i] = api.Rate{
rate := api.Rate{
Start: slot,
End: slot.Add(time.Hour),
Price: t.totalPrice(price),
}
res = append(res, rate)
}

return res, nil
Expand Down

0 comments on commit fc37713

Please sign in to comment.