Widen category place search cap for brand-dedup headroom - #444
Merged
Conversation
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
approved these changes
Jul 29, 2026
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.
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: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 identicallimitblock 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_CATEGORYto 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.