Repository navigation
Conversation
…1591) * docs(web): openapi min rating and rating sort read the shown rating The products API's minRating (alias rating) and the rating_desc sort follow rate.search_master_products, which reads rating_score_5, the rating every page shows, once DOS.Me 20261104140000 is applied: the minimum at one decimal, the sort unrounded, unrated products last. Refs #1545 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(db): mirror the search trigram and rating score migrations Copies two DOS.Me migrations byte for byte from DOS.Me main 13579714 (DOS/DOS.Me#1537, applied to Production): - 20261104120000_rate_search_master_products_trgm_index_and_numeric_guard (DOS/DOS.Me#1497): the seven-field trigram index and the spec number guard in rate.search_master_products; - 20261104140000_rate_search_master_products_rating_score (#1574, via DOS/DOS.Me#1533): the rating order and minimum rating read the rating every page shows. Same signature and return type, so database.types.ts is unchanged (gen-db-types --check passes). Refs #1545 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Promote dev to main.
Merge with a merge commit, never squash (Docs/Resources/RELEASE.md).
📌 TL;DR
This PR optimizes the
rate.search_master_productsdatabase function by adding a trigram index for full-text search and implementing a numeric guard to prevent crashes from malformed spec data. It also aligns the rating filter and sort logic with the exact rating score displayed on the frontend, ensuring consistency between search results and product pages.🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/server/rate/openapi.tsminRatingandsortquery parameters to accurately reflect the new rating logic (usingrating_score_5and one-decimal precision) and the specific behavior of therating_descsort order.supabase/migrations/20261104120000_rate_search_master_products_trgm_index_and_numeric_guard.sql1. Creates a new GIN trigram index (
idx_master_products_search_full_trgm) covering all 7 searchable text fields to enable index-based text search.2. Rewrites
rate.search_master_productsinplpgsqlwithforce_custom_planto allow the planner to simplifyORconditions and utilize the new index.3. Adds a numeric guard for refresh rate, fast charging, and screen size filters to prevent SQL errors when casting malformed spec strings (e.g., "120.5.6") to
NUMERIC.supabase/migrations/20261104140000_rate_search_master_products_rating_score.sql1. Updates
rate.search_master_productsto use a unified "shown rating" calculation (rating_score> 0, else weighted user rating, else average rating) for both filtering and sorting.2. Ensures the
minRatingfilter compares against the rating rounded to one decimal place (matching the UI display).3. Ensures
rating_descsorting uses the unrounded "shown rating" value, placing unrated products last.📊 Architectural Flow
flowchart TD subgraph Client A[API Request] -->|Query Params: search, minRating, sort| B[OpenAPI Spec] end subgraph Database B --> C{rate.search_master_products} subgraph Search Logic C --> D[Text Search] D -->|Uses| E[(idx_master_products_search_full_trgm)] D -->|Guard| F[ILIKE Match] end subgraph Rating Logic C --> G[Calculate Shown Rating] G -->|Priority 1| H[rating_score] G -->|Priority 2| I[user_rating_weighted] G -->|Priority 3| J[average_rating] G --> K[Filter: minRating] K -->|Compares| L[Round to 1 decimal] G --> M[Sort: rating_desc] M -->|Uses| N[Unrounded Value] end subgraph Spec Parsing C --> O[Parse Specs] O -->|Guard| P[Valid Numeric Cast] O -->|Invalid| Q[Treat as Unknown/0] end C --> R[Return Results] end R --> S[Frontend Display] S -->|Matches| T[Product Page Rating]