Registry Mirror
Skip to content

Conversation

@grandnode-dev

@grandnode-dev grandnode-dev commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Type: bugfix

Issue

The storefront read far more reservation slots than it shows, and the month endpoint answered for any product:

  • ProductController.GetDatesForMonth loaded 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 only Id and Date.
  • GetProductDetailsPageHandler.PrepareProductReservation loaded every vacant slot on each product page render to find the first date and the parameter list. The parameter list included past slots.
  • The cart validator and the cart hold (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.GetProductReservationsByProductId takes from (inclusive) and to (exclusive), applied in the query (index ProductId + Date). They replace the one-day date filter, which every caller passed as null. A new trailing optional parameter filters by parameter in the query.
  • New GetFirstVacantDates(productId, from, excludedIds): one grouped query that returns the first vacant date of each parameter.
    • The result is ordered by date, then by name. A missing and an empty parameter count as one "none".
    • Slots in excludedIds are left out.
    • MongoDB runs the query as $group/$min. On LiteDB, Table is in memory, as before.
  • Storefront visibility is one rule, ProductController.CanViewOnStorefront, used by the product page, quick view and the calendar endpoint:
    • published, or previewable through AllowViewUnpublishedProductPage / ManageProducts;
    • ACL and store mapping;
    • availability window, unless the product is an auction or the customer is a catalog manager.
  • GetDatesForMonth:
    • returns [] for a product the customer may not see, or for an invalid or past month;
    • queries only max(month start, now) up to the next month start, with the parameter in the query;
    • returns { Id, Date } per date.
  • Product page: one GetFirstVacantDates call, leaving out the slots in the customer's cart.
    • The calendar opens on the first slot still free.
    • A parameter with nothing left is not offered.
    • Parameters keep the order of their first free slot, as before.
  • 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 by TryBook (moved there unchanged), the cart validator and the cart hold.
  • Clear old reads only slots before now.

Left as they are, on purpose:

  • Grouping per date (any resource free → day free) and the UTC display: R12 and R7.

Breaking changes

IProductReservationService.GetProductReservationsByProductId(productId, showVacant, date, …) becomes (productId, showVacant, from, to, …, parameter). GetFirstVacantDates is new. Every caller in the repository is updated. A plugin that passed a non-null date would need from: day, to: day.AddDays(1).

Testing

Automated:

  • ProductReservationServiceTests (real MongoDB test repository):
    • range bounds and the parameter filter;
    • GetFirstVacantDates: one entry per parameter, ordered by date then by name; past, booked and other-product slots ignored; excluded ids skipped; empty result.
  • ProductControllerReservationDatesTests:
    • unknown, unpublished, previewed, ACL-hidden and other-store products;
    • a product outside its availability window, for a customer and for a catalog manager;
    • invalid, past and current month;
    • the parameter passed to the query;
    • { Id, Date } only, one per date, cart slots left out.
  • Cart validator and cart hold tests now expect the rental-period range. The Clear old test expects to = now.
  • Catalog, Checkout, Web, Admin, Store and Vendor test projects pass in full. The full solution builds.

Manual (shared reservations E2E DB):

  1. Climbing wall: the page lists Advanced, Beginner and opens on 12/01/2026. December gives 192 dates (24 days × 8 hours) with keys Id and Date only; parameter=Beginner returns Beginner slots.
  2. Tent: December gives 28 dates, 24–26 Dec absent. The current month (no slots yet), January 2025, month 13 and an unknown product give [].
  3. Customer, day ranges: tent 7–9 Dec added; tent 22–28 Dec rejected ("No free bookings in this period"); e-bike 10–12 Dec added. The cart page shows no warnings, and 5 day holds are stored (2 tent nights, 3 e-bike days).
  4. Climbing wall reduced to two slots, A (1 Dec, Beginner) and B (1 Jan, Advanced). Before A is in the cart, the page opens on December and lists Beginner, Advanced (date order). With A in the cart, it opens on January and lists only Advanced; December gives [] and January gives B.
  5. Clear old on the tent with 2 extra past slots: vacant slots go from 725 to 723, with no past slot left.
  6. Tent outside its availability window: a guest gets 404 for the page, success:false for quick view and [] for the calendar. The admin gets the page, quick view and 28 dates (preview).
  7. E-bike limited to another customer group: 404, success:false and [] for guest and admin alike, as the product page did before.
  8. In the browser, the climbing wall hour picker loads the month and lists 8 hours for 2 Dec. A Sunday is not marked.

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.
Copilot AI balanced review requested due to automatic review settings November 29, 2026 18:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

- 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.
@grandnode-dev
grandnode-dev merged commit c147b95 into develop Nov 29, 2026
9 checks passed
@grandnode-dev
grandnode-dev deleted the fix/reservation-storefront-queries branch November 29, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants