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
- 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.
- Force-update buttons appear “gone.” On
mainthe 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=1toggle, so ops think they’re missing. - 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.jsalready 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 thechosen-selectclass, no new dependency.- The force-update buttons are all still present in
_overview.html.erb, butfour_hours/one_dayare gated behind@advanced(?advanced=1) - whereas onmainthey showed directly, gated only byuse_third_party_inventory?ANDRAILS_ENV_REAL != production.four_daysvisibility 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.activeandallow_bookingalready flag correctly (verified).
- this skips expiry for ANY present expiry date, including a past one.
Verified: an expired restaurant returns
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
- The package dropdown is searchable (type-to-filter by name/id/slug), valid-first order preserved. No new JS dependency.
four_hoursandone_daybuttons show without?advanced=1, gateduse_third_party_inventory?+ non-production (matching main);four_daysunchanged.- 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 orallow_booking=offrestaurant still flags (regression check). - 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_bookinglogic (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)