chore: use slot wrapper only where necessary

This commit is contained in:
andig 2025-10-05 08:14:05 +02:00
parent a48d3432c2
commit f8ceb65f0e

View file

@ -28,5 +28,10 @@ func NewFromConfig(ctx context.Context, typ string, other map[string]interface{}
return nil, fmt.Errorf("cannot create tariff type '%s': %w", typ, err)
}
// check slot length
if rr, err := v.Rates(); err == nil && len(rr) > 0 && rr[0].End.Sub(rr[0].Start) == SlotDuration {
return v, nil
}
return &SlotWrapper{Tariff: v}, nil
}