Skip to content

fix(proposals): backfill every master with a reviewed listing - #1559

Merged
JOY (JOY) merged 1 commit into
devfrom
fix/1543-backfill-reviewed-listings
Oct 31, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
fix/1543-backfill-reviewed-listings

Conversation

@JOY

@JOY JOY (JOY) commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1543

A fix to the P2 criteria ratings proposal (PR #1549), found while porting it to DOS-Me. Nothing is applied to any database.

The bug

The backfill (section 8 of Docs/Proposals/2026-10-31-dos-me-criteria-ratings.sql) picked masters by the cached authentic_review_count > 0 OR user_rating_weighted > 0. A master can have a counted review while that cache says 0, for example when a review weight is written straight to rate.reviews. Such a master was skipped, kept no rating_score, and V6 of the verify file flagged it. The DOS.Me rate schema replay caught this after a rollback and re-apply.

The fix

The backfill now also picks any master with a reviewed listing (EXISTS a review on a listing whose cluster_id is the master). The cached test stays, for Item variants whose reviews sit on listings with no variant. The refresh still writes only rows whose values change.

Test

scripts/test-criteria-ratings-proposal.mjs zeroes the 256GB master's cached count and weighted rating before the first apply, then checks the backfill still gives it 3.650|1.00|{}. It then restores the cache and runs the rest unchanged.

  • With the fix: the whole replay passes locally.
  • With the old backfill: it fails at the new check ("the backfill rates a master with a stale count on the reference stack").

The DOS.Me copy of the migration already carries the same change: branch claude/rate-1543-criteria-ratings, commit 7d2e109; its PR is not open yet.

🤖 Generated with Claude Code


📌 TL;DR

This PR fixes a data integrity gap in the rating backfill process by ensuring masters with stale authentic_review_count caches are still correctly rated if they have active reviews on their listings. It also adds a regression test to verify this behavior.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
Docs/Proposals/2026-10-31-dos-me-criteria-ratings.sql Updated the SELECT query for refresh_master_rating_extras to include an EXISTS check for reviews on linked products. This ensures masters are processed even if their cached authentic_review_count is stale (e.g., zero) but actual reviews exist.
scripts/test-criteria-ratings-proposal.mjs Added a regression test that simulates a stale cache scenario (setting authentic_review_count to 0) and asserts that the backfill logic still correctly calculates and applies the rating.

📊 Architectural Flow

flowchart TD
    A[Start Backfill] --> B{Check Master Products}
    B --> C{Has Stale Cache?}
    C -->|Yes| D[Check for Active Reviews via EXISTS]
    C -->|No| E[Check Cached Counts]
    D --> F{Reviews Found?}
    F -->|Yes| G[Include in Refresh Set]
    F -->|No| H[Exclude from Refresh Set]
    E --> I{Counts > 0?}
    I -->|Yes| G
    I -->|No| H
    G --> J[Execute refresh_master_rating_extras]
    H --> K[Skip Master]
    J --> L[Commit Transaction]
Loading

The criteria ratings backfill picked masters by the cached
authentic_review_count or user_rating_weighted. A master whose review
weight was written straight to rate.reviews keeps a stale count of 0 and
was skipped, so V6 failed. The DOS.Me replay caught it. The backfill now
also picks any master with a reviewed listing; the cached test stays for
Item variants whose reviews sit on listings with no variant.

The Docker replay zeroes the 256GB master's cached count before the first
apply and checks the backfill still rates it; it fails on the old filter.

Refs #1543

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

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.

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Oct 31, 2026 8:39pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b802d4f-589d-41a6-8bed-1efc7ee8a3cc
Commits

Reviewing files that changed from the base of the PR and between e97b94c and 4a17b72.

Files selected for processing: 2
  • Docs/Proposals/2026-10-31-dos-me-criteria-ratings.sql
  • scripts/test-criteria-ratings-proposal.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

dos[bot]
dos Bot approved these changes Oct 31, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (2 eligible files · 2,239 chars · 1 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base e97b94c / head 4a17b72.

✅ CLEAN_PASS: Complete diff reviewed

@JOY
JOY (JOY) merged commit cc57e2d into dev Oct 31, 2026
18 checks passed
@JOY
JOY (JOY) deleted the fix/1543-backfill-reviewed-listings branch October 31, 2026 20:45

This branch was successfully deployed

1 active deployment
Preview — 4a17b72b Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant