Skip to content

Widen category place search cap for brand-dedup headroom - #444

Merged
timwangmusic merged 1 commit into
masterfrom
feat/wider-category-limit
Jul 29, 2026
Merged

Widen category place search cap for brand-dedup headroom#444
timwangmusic merged 1 commit into
masterfrom
feat/wider-category-limit

Conversation

@tim-eternos

Copy link
Copy Markdown
Collaborator

Why

OfferBee's Best Card → Location "Food & drink" list is chain-dominated — a live audit returned 9 Starbucks in the nearest 20. The client will dedup by brand (one location per merchant), but with only 20 candidates the deduped list ends up sparse and farther unique local spots never appear. The category endpoint needs a bigger pool.

Change

getNearbyPlacesByCategory:

  • Raise the per-category cap 20 → 40, and clamp over-cap values instead of the old limit > 20 → 5, which silently gutted any larger request back to the tiny default.
  • DetailsLimit: min(limit, 20) so widening the pool only adds Nearby-Search pagination (already parallelized across place types), not expensive Place Details calls — cost stays ~today's.

getNearbyPlaces (brand) shares the identical limit block and gets the same clamp; no behavior change in practice since brand callers pass small limits (≤20).

Testing

go build ./..., go test ./planner/... ./iowrappers/... pass.

Pairs with an OfferBee-side change that bumps PLACES_PER_CATEGORY to 40 and dedups by brand. Deploy note: this needs to reach Heroku (git push heroku master) before the client requests 40 — otherwise the pre-deploy cap sends >20 back to 5.

The merchant/category endpoint needs a bigger candidate pool: downstream
brand-dedup (keep one location per brand) collapses chain-dense results (e.g. 9
Starbucks in the nearest 20), so with only 20 candidates the list is left sparse
and farther unique local spots never surface.

- getNearbyPlacesByCategory: raise the per-category cap 20 → 40, and CLAMP rather
  than fall back to 5 for over-cap values (the old `> 20 → 5` silently gutted any
  larger request). DetailsLimit is bounded to min(limit, 20) so the widened pool
  only adds Nearby-Search pagination (parallelized by the earlier change), not
  expensive Place Details calls — cost stays ~today's.
- getNearbyPlaces (brand) shares the identical limit block; it gets the same
  clamp. No behavior change in practice — brand callers send small limits (<=20).

go build + go test (planner, iowrappers) pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cv6h62pnPJZykmbsmppuSy
@timwangmusic
timwangmusic merged commit 165b957 into master Jul 29, 2026
4 checks passed
@timwangmusic
timwangmusic deleted the feat/wider-category-limit branch July 29, 2026 02:10
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