DayHoursDisplay renders an interval with a discount as 08:00 - 09:00 (10), and RE_HOURS accepts that format, but DayHour::try_from does not parse it — it fails with HourParseError and never sets discount (it is always None).
Verified: 08:00 - 09:00 (10) passes WeekHours::validate() and fails DayHours::try_new().
Impact
Currently latent: a discount cannot be entered through the UI, so opening_hour.discount is normally NULL. As soon as a row has a discount, the edit dialog is pre-filled with the (10) suffix and saving it fails with a server error. update_hours also deletes and re-inserts the rows, so even without the error the discount could not survive an edit.
Suggested fix
Teach DayHour::try_from to parse the optional (N) suffix into discount, and add a round-trip unit test with a discount (the existing day_hours_display_round_trip covers only intervals without one). Alternatively, if discounts per interval are not a planned feature, remove them from Display and from the regex.
Found while writing unit tests (#2).
## Problem
`DayHours` `Display` renders an interval with a discount as `08:00 - 09:00 (10)`, and `RE_HOURS` accepts that format, but `DayHour::try_from` does not parse it — it fails with `HourParseError` and never sets `discount` (it is always `None`).
Verified: `08:00 - 09:00 (10)` passes `WeekHours::validate()` and fails `DayHours::try_new()`.
## Impact
Currently latent: a discount cannot be entered through the UI, so `opening_hour.discount` is normally `NULL`. As soon as a row has a discount, the edit dialog is pre-filled with the `(10)` suffix and saving it fails with a server error. `update_hours` also deletes and re-inserts the rows, so even without the error the discount could not survive an edit.
## Suggested fix
Teach `DayHour::try_from` to parse the optional `(N)` suffix into `discount`, and add a round-trip unit test with a discount (the existing `day_hours_display_round_trip` covers only intervals without one). Alternatively, if discounts per interval are not a planned feature, remove them from `Display` and from the regex.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Found while writing unit tests (#2).
Problem
DayHoursDisplayrenders an interval with a discount as08:00 - 09:00 (10), andRE_HOURSaccepts that format, butDayHour::try_fromdoes not parse it — it fails withHourParseErrorand never setsdiscount(it is alwaysNone).Verified:
08:00 - 09:00 (10)passesWeekHours::validate()and failsDayHours::try_new().Impact
Currently latent: a discount cannot be entered through the UI, so
opening_hour.discountis normallyNULL. As soon as a row has a discount, the edit dialog is pre-filled with the(10)suffix and saving it fails with a server error.update_hoursalso deletes and re-inserts the rows, so even without the error the discount could not survive an edit.Suggested fix
Teach
DayHour::try_fromto parse the optional(N)suffix intodiscount, and add a round-trip unit test with a discount (the existingday_hours_display_round_tripcovers only intervals without one). Alternatively, if discounts per interval are not a planned feature, remove them fromDisplayand from the regex.