Conversation
The generator moves from BaseProductReservationController into
IProductReservationService.GenerateCalendar and its bugs are fixed:
- the guard against switching between day and hour slots compared the
interval instead of the unit, so it never fired;
- GenerateCalendarModel had no validator: an empty date was a 500 and
the ModelState branch was dead;
- a second Generate doubled hour and minute slots; now only the missing
quantity of a date, resource and parameter is added;
- more than 1000 slots stopped silently mid-range behind catch {}; now
nothing is written and the limit is reported;
- hour slots were aligned to midnight instead of the start time;
- the product fields were saved before the generation could fail.
The tab reports the slots added and skipped in a status line instead of
alert().
Review fixes for the calendar generator: - a day slot without a resource is stored as null again, as before: FindGroupToBook groups by the stored resource, so "" next to null split one resource in two and a range across both could not be booked; - the read of existing slots and the inserts run under the product's lock that TryBook takes, so two generations at once add the plan once; - the range query ends on the last tick of the end date instead of a day after it, which overflowed on 9999-12-31; - minute and hour intervals must be shorter than a day: their slots fill the hours of each day, and a huge interval overflowed TimeSpan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
The reservation calendar generator lived in
BaseProductReservationController.GenerateCalendar(shared by Admin, Store and Vendor), untested, with several bugs:(IntervalUnit)model.Intervalinstead ofmodel.IntervalUnit, so the day-to-hour direction never fired.GenerateCalendarModelhad no validator. An empty date threw (500), and theModelStatebranch was dead code.catch { }.Solution
IProductReservationService.GenerateCalendar(product, ReservationCalendarPlan)returns aReservationCalendarResult(created, skipped, limit reached, unit changed):ReservationCalendarPlan.MaxSlots(1000) new slots: nothing is written and the limit is reported, so no calendar is left half-generated;TryBookalready takes, so two generations at once (a double click, two staff members) add the plan once;nullwhen the field is empty, becauseFindGroupToBookgroups by the stored resource and a""next tonullwould split one resource in two.GenerateCalendarModelValidator: both dates required, end ≥ start, interval > 0, a known unit, at least one day of the week; for minute/hour units, quantity > 0, an interval shorter than a day (their slots fill the hours of each day; a longer step is a calendar by days) and the end time not before the start time. Equal times are allowed: the end time is the last slot of a day, so they give one slot a day.{ success, message }with the counts.alert().GrandAdminhas no notification widget, so an inlinerole="status"alert is the smallest fit.DefaultLanguage.xmlandUpgrade/en_250.xml.Left as they are, on purpose:
IRepository<T>has noInsertMany. Adding one would change a shared API with four implementations, including the auditing ones. Slots still go throughInsertProductReservation, one entity event each, now capped at 1000.Product.IntervalUnitId, as before: slots do not store their unit.Breaking changes
None.
IProductReservationServicegains a method.Testing
Automated:
ProductReservationServiceTests(real MongoDB test repository, run in CET: day, minute alignment, week-day filter, re-run adds only the missing quantity, another parameter/resource is not a duplicate, limit, both unit-change directions),GenerateCalendarModelValidatorTests,BaseProductReservationControllerTests(generator cases replaced). Catalog, Checkout and Admin test projects pass in full.Manual (done on a store with sample data on a CET server):
Beginner) → Calendar tab → generate the same day and hours again → "Slots added: 0. Already in the calendar: 8."; with quantity 2 → 8 added; again → 0 added, 16 skipped.