Skip to content

Fix compatibility ranking and saved-search scalability#39

Merged
sumit1642 merged 2 commits into
tier0from
fix/listing-ranking-saved-search-scale
May 26, 2026
Merged

Fix compatibility ranking and saved-search scalability#39
sumit1642 merged 2 commits into
tier0from
fix/listing-ranking-saved-search-scale

Conversation

@sumit1642

@sumit1642 sumit1642 commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes three backend issues affecting listing ranking quality, saved-search alert scalability, and saved-search cap integrity.

Changes

  • Apply listing compatibility ranking in SQL before limiting results.
  • Add compatibility pagination using cursorScore and cursorId.
  • Preserve existing recent listing keyset pagination using cursorTime and cursorId.
  • Refactor saved-search alerts from per-search queries to batched SQL matching.
  • Add bulk-friendly notification enqueue support.
  • Make saved-search limit enforcement atomic with transaction advisory locking.
  • Add a DB trigger migration enforcing the 10 active saved-search cap per user.

Why

Previously, sortBy=compatibility only reordered a recency-limited subset, so better matches could be missed. Saved-search alerts also performed one query per saved search, which would not scale. Saved-search creation used a non-atomic count-then-insert flow, allowing concurrent requests to exceed the cap.

Validation

  • node --check passed for changed JS files.
  • git diff --check passed.
  • Import check passed for changed modules.
  • Read-only DB compatibility search executed successfully.
  • Saved-search alert SQL verified with EXPLAIN.
  • Migration DDL verified inside a rollback-only transaction.
  • Validator script confirmed compatibility and recent cursor behavior.
  • npm test -- --runInBand could not run because node_modules/.bin/jest is missing.

Summary by CodeRabbit

Release Notes

  • New Features

    • Users can now save up to 10 active searches per account.
  • Improvements

    • Enhanced search alert and notification delivery efficiency with improved batching.
    • Refined compatibility-based pagination for more consistent listing search results.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@sumit1642, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 9 minutes and 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd4ef5fe-91a8-4071-ba0d-aa8ac1a70959

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5dd22 and c07d254.

📒 Files selected for processing (7)
  • migrations/010_saved_search_cap.sql
  • src/cron/savedSearchAlert.js
  • src/services/listing.service.js
  • src/services/savedSearch.service.js
  • src/validators/listing.validators.js
  • src/validators/pagination.validators.js
  • src/workers/notificationQueue.js

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (2)
Validation error: Invalid option: expected one of "chill"|"assertive" at "reviews.profile"; Invalid input: expected string, received boolean at "reviews.high_level_summary_placeholder"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/listing-ranking-saved-search-scale

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@sumit1642 sumit1642 self-assigned this May 26, 2026
@sumit1642 sumit1642 added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed labels May 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cron/savedSearchAlert.js`:
- Around line 83-89: The current query uses the updated_searches CTE to set
saved_searches.last_alerted_at before calling enqueueNotificationsBulk, which
causes at-most-once delivery if enqueue fails; either document this guarantee or
change the flow so you first SELECT/RETURN the matched search rows (use the
matched_searches CTE or a RETURNING list), call enqueueNotificationsBulk with
that list, and only after enqueue succeeds run an UPDATE on saved_searches to
set last_alerted_at for the returned search_ids; reference the updated_searches
CTE, matched_searches, saved_searches, last_alerted_at and the
enqueueNotificationsBulk call and perform the UPDATE post-enqueue (or wrap
enqueue + UPDATE in a durable transaction/mechanism) to achieve at-least-once
delivery.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7dface08-bb50-4c67-bf42-bcc0c36e7fd5

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5dd22 and 31f5200.

📒 Files selected for processing (7)
  • migrations/010_saved_search_cap.sql
  • src/cron/savedSearchAlert.js
  • src/services/listing.service.js
  • src/services/savedSearch.service.js
  • src/validators/listing.validators.js
  • src/validators/pagination.validators.js
  • src/workers/notificationQueue.js

Comment thread src/cron/savedSearchAlert.js Outdated
@sumit1642

Copy link
Copy Markdown
Owner Author

@CodeRabbit review latest changes

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

@sumit1642 Sure! I'll kick off a full review of the latest changes in PR #39 right away.

✅ Actions performed

Full review triggered.

@sumit1642

Copy link
Copy Markdown
Owner Author

@CodeRabbit review latest changes

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

@sumit1642 Sure! Triggering a full review of the latest changes in PR #39 now.

✅ Actions performed

Full review triggered.

@sumit1642 sumit1642 merged commit d9c6d39 into tier0 May 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant