Repository navigation
fix(menu): treat items outside their sale hours as unavailable - #63
Merged
Merged
Conversation
Wolt assortment items carry available_times: weekly sale windows in the venue's local time (ISO weekdays, milliseconds since local midnight). A lunch dish sold only on Mondays 10:30-15:00 keeps disabled_info = null all week, so the CLI listed it as available, cart add accepted it and checkout preview priced it. Wolt's basket marked the line is_available=false and left it out of the basket total, which failed the daily live smoke with "Wolt basket total 0 != CLI subtotal 2900" (issue #62). The gateway client now checks available_times on every assortment response (full menu, category, items, search). For items outside their window it writes a disabled_info with a reason such as "not sold now; available Mon 10:30-15:00 Europe/Helsinki", which the menu, item, cart add and checkout checks in the CLI and MCP already honour. The venue timezone comes from the static venue page, is fetched only when an item is restricted at all, and is cached per venue. When it cannot be read, items stay as Wolt returned them. time/tzdata is embedded so Windows builds resolve the zone too. `wolt cart` now passes Wolt's per-line is_available through and warns for each unavailable line, since Wolt's total then differs from the subtotal.
Looking up the venue timezone on the static venue page added one static request per venue menu with restricted items. Wolt rate-limits that endpoint for GitHub runner IPs: after the live smoke's menu crawl, the static lookup inside `cart add <venue-id>` got 429 and the add failed with WOLT_ITEM_AVAILABILITY_UNKNOWN. The client now records each venue's zone from the venue pages it loads anyway: the IANA zone of a static page (under the requested reference, its slug and its id) and the UTC offset of open_status.now on a dynamic page. A menu load and a cart add therefore need no extra request. When no page was loaded, the client asks the dynamic page, and the static page is the last resort. An offset expires after an hour so a long-running MCP server picks up a DST switch. The unavailable reason says "venue time" instead of the zone name, since an offset has none.
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.
Summary
The daily live smoke failed because it put a lunch dish into the cart outside lunch hours. Wolt sells that dish only on Mondays from 10:30 to 15:00. The CLI ignored those hours: it listed the dish as available, let
cart addput it in the basket and priced it at checkout. Wolt itself marked the basket line unavailable and counted the basket total as 0.Now the CLI and the MCP server read each dish's sale hours in the restaurant's local time. Outside those hours the dish shows as unavailable with a reason such as "not sold now; available Mon 10:30-15:00 venue time". Adding it to the cart or previewing checkout is refused.
wolt cartalso warns when Wolt marks a line in the basket unavailable.Nothing from you: the fix ships as v2.5.3 after CI passes.
Fixes #62
Details
available_times: weekly windows, ISO weekdays (1 = Monday), start and end in milliseconds since venue-local midnight.disabled_infostaysnulloutside the window.disabled_infofor items outside their window. Existing availability checks in the CLI and MCP honour it unchanged.open_status.now). A menu load and a cart add need no extra request. Otherwise the client asks the dynamic page once, and the static page is the last resort. If neither works, items stay as Wolt returned them.cart add <venue-id>then failed withWOLT_ITEM_AVAILABILITY_UNKNOWN.time/tzdatais embedded so Windows builds resolve the zone.wolt cartpasses Wolt's per-lineis_availablethrough and adds a warning for each unavailable line.Testing
cart addfails withWOLT_ITEM_UNAVAILABLE. Before the fix the same add succeeded, and Wolt returned the line withis_available: falseandbasket_total: 0.disabled_infowinning.go build,golangci-lint run,go test ./...,go test -race ./....