feat: dual-sort reviews — merge relevant + newest for ~10 reviews#64
Merged
feat: dual-sort reviews — merge relevant + newest for ~10 reviews#64
Conversation
… place Google Places API (New) returns max 5 reviews sorted by relevance. This change fetches an additional 5 newest reviews via Legacy Place Details API (which supports reviews_sort=newest), then merges and deduplicates by author+timestamp. Result: place_details now returns ~10 reviews instead of 5, with both high-quality relevant reviews and the most recent ones — enabling better AI context classification and trend detection. Also fixes Prettier formatting inconsistencies from PR #63 squash merge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Google Places API (New) hard-limits responses to 5 reviews (sorted by relevance). This PR doubles the review count by fetching an additional 5 newest reviews via the Legacy Place Details API (
reviews_sort=newest), then merging and deduplicating.Before: 5 reviews (most relevant only)
After: ~10 reviews (5 most relevant + 5 newest, deduplicated)
How it works
getPlaceDetailscalls Places API (New) via gRPC → 5 most relevant reviewsreviews_sort=newest→ 5 newest reviewsauthor_name + timestampWhy two APIs?
places.getdoes NOT supportreviews_sortparameter (returns 400)reviews_sort=newestand returns completely different reviewsCost impact
One additional Legacy Place Details API call per
maps_place_detailsinvocation. Only requests thereviewsfield, so it falls under the lowest billing tier.Test result
Test plan
npm run format:check— passesnpm run build— passesnpm test— 168 passed, 0 failedRelated: #61 (Phase 4a)
🤖 Generated with Claude Code