fix(pages): repair pagination follow-ups#341
Conversation
Greptile SummaryThis PR fixes three distinct regressions introduced by the previous pagination merge: mojibake (UTF-8 characters rendered as Latin-1 sequences) across eight listing pages, an inflated
Confidence Score: 5/5Safe to merge; the Unicode repairs are mechanical and correct, the pagination cap is a sound tightening, and the reviews average calculation is a genuine improvement over the old page-slice approach. All three goals are achieved cleanly. The reviews route now correctly aggregates across all rows rather than just the visible page. The only notable wrinkle is a theoretical race window where a concurrent review deletion between the two database queries triggers a 500 rather than a graceful partial compute, but review deletions are uncommon and the window is sub-millisecond, making this unlikely to surface in practice. src/app/api/users/[username]/reviews/route.ts — the strict length guard on the ratings query could return 500 under concurrent deletions. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ReviewsRoute as GET /api/users/[username]/reviews
participant Supabase
Client->>ReviewsRoute: "GET ?limit=10&offset=0"
ReviewsRoute->>Supabase: "SELECT profiles WHERE username=? (single)"
Supabase-->>ReviewsRoute: profile.id
ReviewsRoute->>Supabase: "SELECT reviews (paginated, count=exact)"
Supabase-->>ReviewsRoute: reviews[], count
alt "totalReviews > 0"
ReviewsRoute->>Supabase: SELECT rating FROM reviews .range(0, totalReviews-1)
Note over ReviewsRoute,Supabase: Race window: review could be deleted here
Supabase-->>ReviewsRoute: allRatings[]
alt "allRatings.length !== totalReviews"
ReviewsRoute-->>Client: 500 Unable to calculate average rating
else counts match
ReviewsRoute-->>Client: "200 {data, summary, pagination}"
end
else "totalReviews == 0"
ReviewsRoute-->>Client: "200 {data, summary:{average_rating:0}, pagination}"
end
Reviews (2): Last reviewed commit: "fix(reviews): bound average rating query" | Re-trigger Greptile |
|
Addressed the Greptile note in 18d1d17: the all-ratings query now explicitly ranges from 0 to |
Summary
parsePageParamdefault max page from 100,000 to 1,000 and update coverageFixes #340.
Verification
?,?, replacement char) and found no matches after the repair.