Conversation
The month calendar endpoint read every vacant slot of the product and filtered the month in memory, never checked that the customer may see the product, and returned whole slot documents. The product page read every vacant slot on each render for the first date and the parameter list, past slots included. GetProductReservationsByProductId takes a from/to range applied in the query, in place of the day filter no caller used. GetFirstVacantDate and GetVacantParameters answer the product page from the database. GetDatesForMonth checks the product like the product page (published or previewable, customer groups, store), queries only the month from now on, and returns the slot id and date.
- The calendar endpoint also checks the availability window, through one storefront visibility rule now shared by the product page and its quick view. - The product page reads, in one grouped query, the first vacant date of each parameter, leaving out the slots in the customer's cart: the calendar no longer opens on a month whose only free slot is in the cart, a parameter with nothing left is not offered, and parameters keep the order of their first free slot. - The month endpoint filters the parameter in the query. - The cart validator and the cart hold read only the slots around the rental period, and Clear old reads only past slots. - The current-month test is inconclusive when the month ends while it runs.
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 storefront read far more reservation slots than it shows, and the month endpoint answered for any product:
ProductController.GetDatesForMonthloaded every vacant slot of the product and filtered month, year and parameter in memory. It never checked that the customer may see the product (published, availability window, customer groups, store), so it listed the free dates of a hidden product. It returned whole slot documents, while the calendar script reads onlyIdandDate.GetProductDetailsPageHandler.PrepareProductReservationloaded every vacant slot on each product page render to find the first date and the parameter list. The parameter list included past slots.AddCustomerReservationCommandHandler) loaded the product's whole free calendar to check one rental period. The admin Clear old action loaded every free slot to keep the past ones.Solution
IProductReservationService.GetProductReservationsByProductIdtakesfrom(inclusive) andto(exclusive), applied in the query (indexProductId + Date). They replace the one-daydatefilter, which every caller passed asnull. A new trailing optionalparameterfilters by parameter in the query.GetFirstVacantDates(productId, from, excludedIds): one grouped query that returns the first vacant date of each parameter.excludedIdsare left out.$group/$min. On LiteDB,Tableis in memory, as before.ProductController.CanViewOnStorefront, used by the product page, quick view and the calendar endpoint:AllowViewUnpublishedProductPage/ManageProducts;GetDatesForMonth:[]for a product the customer may not see, or for an invalid or past month;max(month start, now)up to the next month start, with the parameter in the query;{ Id, Date }per date.GetFirstVacantDatescall, leaving out the slots in the customer's cart.ProductReservationExtensions.SlotRangeOfRentalPeriod(start, end)gives the slot range to read for a rental period: a day either side, because only the date part of a stored slot counts. It is used byTryBook(moved there unchanged), the cart validator and the cart hold.Left as they are, on purpose:
Breaking changes
IProductReservationService.GetProductReservationsByProductId(productId, showVacant, date, …)becomes(productId, showVacant, from, to, …, parameter).GetFirstVacantDatesis new. Every caller in the repository is updated. A plugin that passed a non-nulldatewould needfrom: day, to: day.AddDays(1).Testing
Automated:
ProductReservationServiceTests(real MongoDB test repository):GetFirstVacantDates: one entry per parameter, ordered by date then by name; past, booked and other-product slots ignored; excluded ids skipped; empty result.ProductControllerReservationDatesTests:{ Id, Date }only, one per date, cart slots left out.to = now.Manual (shared reservations E2E DB):
Advanced,Beginnerand opens on 12/01/2026. December gives 192 dates (24 days × 8 hours) with keysIdandDateonly;parameter=Beginnerreturns Beginner slots.[].Beginner,Advanced(date order). With A in the cart, it opens on January and lists onlyAdvanced; December gives[]and January gives B.success:falsefor quick view and[]for the calendar. The admin gets the page, quick view and 28 dates (preview).success:falseand[]for guest and admin alike, as the product page did before.