Fix DOM-extracted extended reviews - #316
Merged
Merged
Conversation
kostaspt
force-pushed
the
fix-extended-reviews-fields
branch
from
July 25, 2026 12:12
4cbe7ff to
f397b52
Compare
kostaspt
marked this pull request as draft
July 25, 2026 12:27
kostaspt
force-pushed
the
fix-extended-reviews-fields
branch
from
July 25, 2026 12:35
f397b52 to
2968a88
Compare
The DOM fallback for -extra-reviews returned extended reviews with Rating=0 and empty review ids: playwright-go returns Go int for whole JS numbers, so the float64-only assertion always failed, and the data-review-id attribute present on every review card was never read. Decode int and float64 ratings, ignoring values outside 1-5 which come from the non-star aria-labels the rating selectors also match, and carry review_id through to the output. Use it to deduplicate extended entries against the primary reviews, which the panel re-lists: on two live places every primary review reappeared among the extended ones. The dedup logs what it drops, and warns when no id matches at all.
kostaspt
force-pushed
the
fix-extended-reviews-fields
branch
from
July 25, 2026 12:55
2968a88 to
4e5c47e
Compare
kostaspt
marked this pull request as ready for review
July 25, 2026 13:08
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the correctness and usability of the DOM-extraction fallback for extended reviews when the review RPC path is blocked (e.g., HTTP 403). It ensures key identity and rating fields are populated so extended reviews can be joined/deduped against primary reviews instead of silently degrading with “healthy-looking” counts but unusable data.
Changes:
- Fix DOM rating decoding by accepting both
intandfloat64from Playwright and clamping decoded ratings to the 1–5 range. - Extract and propagate DOM
review_idintoReview.ReviewID, enabling reliable identity matching. - Deduplicate DOM-extracted extended reviews against
user_reviewsbyReviewID, with diagnostic logging and unit tests covering decode + dedupe behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gmaps/reviews.go | Adds review_id extraction, robust rating decode, and helper logic to parse and dedupe DOM reviews. |
| gmaps/place.go | Dedupes DOM-derived extended reviews against primary reviews before appending to UserReviewsExtended, with logging. |
| gmaps/dom_reviews_test.go | Adds targeted unit tests for DOM decode, conversion, and deduplication behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
When the review RPC is blocked and the scraper falls back to DOM extraction, every entry written to
user_reviews_extendedhasRating=0,review_id=""andsource="", only the name, text, images and the relativeWhenstring have data. So the extended reviews can't be used for anything rating-based and can't be joined againstuser_reviews.Symptom
All 10 entries per place land with those fields zeroed. The counts look healthy, which makes the degradation easy to miss. Reproduced against
v1.17.2-1419d5d(digestsha256:33c1ec397acbb3038515b5854cb8cea22ab7131a9ecb4b14995e5e982144e755), two real places,-depth 1 -lang en -extra-reviews.Root cause
The rating is read using a
float64type assertion (reviews.go:635before this PR):but playwright-go returns integral JS numbers as Go
int(parseValue,js_handle.go:104-113in v0.6100.0):The extraction script
Math.rounds the rating before pushing it, so the value's always an integer and the assertion fails 100% of the time.review_idandsourcejust never got extracted on this path.What this PR changes
The rating decode now accepts
intandfloat64. The JS side is untouched.review_idis read from the card'sdata-review-idattribute and carried through toReview.ReviewID.With ids populated, extended entries are deduplicated against
user_reviews: on two live test places every primary review reappeared in the extended set (matched heuristically before the fix, confirmed by id identity after, 8/8 per place). Dropping those leaves the genuinely new reviews (10 -> 2 per place). Empty ids never match. Note this changes output for anyone summing both columns (18 -> 10 per place).Decoded ratings are bounded to 1-5, anything out of range reads as unread (0).
If DOM and primary review IDs ever stop overlapping entirely, the dedup logs one line instead of failing silently.
Tests cover the decode edges, the converter, the dedup,.
The switch to index-based loops isn't a style choice, gocritic's rangeValCopy trips once the struct passes 128 bytes.
Known issues NOT fixed here
listugcposts403 itself: this improves the fallback's output, it does not restore the RPC path. Diagnosis is in progress, will follow separately.AuthorURLis extracted by the DOM script but dropped by the converter.Verification
make lint,go build ./...,go test -count=1 ./...,gofmt -s -l gmaps/all clean. Live run against the pinned image with the patched binary, same places and flags: extended entries went from all-zeroed to ratings 1-5 (observed 5, 2, 5, 5, read, not defaulted), non-empty ids, relative times verbatim. Primary reviews unchanged.posted_at_unix_micros/published_atstay zero on purpose, the panel carries no absolute timestamp and nothing is fabricated.Related