Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PRD - Inventories Diagnosis UI Feedback Fixes

Status: Drafted from grilling; ready for build Branch: continues perf/hhserver-vendor-availability-major Tracking: Inventories diagnosis UI feedback fixes #8343 - tracked on PR #8274 Audience: HungryHub Engineering + CS-Ops Relationship to prior work: Corrections to the shipped bookability diagnosis (the overview header verdict, the package dropdown #8334, and the force-update buttons vs main).


1. Problem - three CS-ops feedbacks

  1. Package dropdown is unsearchable. The package selector (#8334) lists all packages (valid-first), but a long tail of inactive packages makes it hard to find one by name/id.
  2. Force-update buttons appear “gone.” On main the overview showed Force Update Supplier Inventory (four_days) plus Force Update Trigger: four_hours and one_day. In the new UI the two short-trigger buttons were moved behind the ?advanced=1 toggle, so ops think they’re missing.
  3. Expired restaurant shows “BOOKABLE / Accepting bookings.” The header restaurant verdict skips the expiry check entirely when an expiry date is present, so an already-expired restaurant (expiry_date < today) reads as bookable.

2. Grounded findings

  • Diagnosis views are plain ERB (server-rendered), layout admin.
  • admin.js already auto-initializes .chosen-select -> selectize (searchable dropdown). Chosen/selectize is the established admin pattern; select2 is NOT a dependency (not in package.json / admin JS). So “searchable” = add the chosen-select class, no new dependency.
  • The force-update buttons are all still present in _overview.html.erb, but four_hours/one_day are gated behind @advanced (?advanced=1) - whereas on main they showed directly, gated only by use_third_party_inventory? AND RAILS_ENV_REAL != production. four_days visibility matches main.
  • restaurant_verdict (bookability_presenter.rb) has: next false if field[:key] == :restaurant_expiry_date && restaurant.expiry_date.present?
    • this skips expiry for ANY present expiry date, including a past one. Verified: an expired restaurant returns :bookable. active and allow_booking already flag correctly (verified).

3. Fixes

Fix 1 - searchable package dropdown (feedback #1)

Add class: "bk-input chosen-select" to the package <select> (and the channel select) in _overview.html.erb. The existing admin .chosen-select -> selectize initializer makes it type-to-search by name/id/slug. No select2, no new dependency. Pairs with the existing valid-first sort (valid surface first and searchable). The form is in the initial _overview shell (not AJAX-re-rendered), so selectize initializes normally on load.

Fix 2 - restore force-update button visibility (feedback #2)

Move four_hours and one_day out from behind ?advanced=1 so they render alongside four_days, gated exactly like main: use_third_party_inventory? AND RAILS_ENV_REAL != production (the two short triggers stay non-prod-only; four_days shows everywhere). Group all three in one force-update action row near the top of the overview.

Fix 3 - expired restaurant must not read “BOOKABLE” (feedback #3)

In restaurant_verdict, change the expiry skip so it only bypasses the future comparison, not an already-expired restaurant:

# before
next false if field[:key] == :restaurant_expiry_date && restaurant.expiry_date.present?
# after
next false if field[:key] == :restaurant_expiry_date &&
              restaurant.expiry_date.present? && restaurant.expiry_date >= today

So: expiry unset -> still flagged; expiry in the future -> skipped at the (date-agnostic) header; expiry in the past -> NOT BOOKABLE (“Restaurant has expired, ended {date}”). active / allow_booking unchanged (already correct).

4. Acceptance criteria

  1. The package dropdown is searchable (type-to-filter by name/id/slug), valid-first order preserved. No new JS dependency.
  2. four_hours and one_day buttons show without ?advanced=1, gated use_third_party_inventory? + non-production (matching main); four_days unchanged.
  3. An expired restaurant (expiry_date < today) shows NOT BOOKABLE at the header with an “expired” reason; a not-yet-expired restaurant is unaffected; an inactive or allow_booking=off restaurant still flags (regression check).
  4. No regression to the package-scoped calendar, party/channel, or parity spec.

5. Non-goals

  • No select2 / new JS dependency (reuse admin selectize).
  • No change to the force-update workers or trigger types.
  • No change to active / allow_booking logic (already correct).
  • No customer-facing changes.

6. Sequencing note (file conflict)

Fix 3 edits bookability_presenter.rb, which is being edited by the concurrent Epic #8339 agent. Fixes 1 & 2 edit only _overview.html.erb (no conflict) and can land first; Fix 3 lands after #8339 is merged/committed so it edits the final restaurant_verdict.

7. Source-of-truth file map

  • app/views/admin/restaurants/inventories/_overview.html.erb (Fix 1 + Fix 2)
  • app/presenters/admin/bookability_presenter.rb#restaurant_verdict (Fix 3)
  • Admin selectize init: app/assets/javascripts/admin.js (.chosen-select)