fix(listings): preserve explicit sort order - #1491
Conversation
|
@iamomm-hack is attempting to deploy a commit to the Superteam Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe query builder now centralizes detection of default featured-prioritized sorting. The listings API reorders featured ongoing listings only for matching queries and preserves database order for other queries. ChangesFeatured listing ordering
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change preserves explicitly selected listing sort orders while retaining the existing default featured-listing behavior. No actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
What does this PR do?
Preserves the user's selected listing sort instead of unconditionally moving featured, ongoing listings to the front of every response.
The query builder intentionally prioritizes featured listings only for the default ordering (
Date, ascending, with anopenorallstatus). The API route previously calledreorderFeaturedOngoingfor every request after Prisma had applied the requested order. That second pass could silently override explicitPrize,Submissions,Status, and descendingDatesorts.This PR extracts the existing default-sort rule into
shouldPrioritizeFeaturedand uses the same predicate in both places:orderByconstructionCustom sorts now retain the database order, while the existing default featured-listing behavior remains unchanged.
Where should the reviewer start?
src/features/listings/utils/query-builder.ts— the sharedshouldPrioritizeFeaturedrule and its use ingetOrderBysrc/app/api/listings/route.ts— conditional response reorderingHow should this be manually tested?
Validation performed locally:
pnpm check-types— passedpnpm lint— completed with 0 errorspnpm exec oxfmt --check src/app/api/listings/route.ts src/features/listings/utils/query-builder.ts— passedgit diff --check— passedAny background context you want to provide?
The mismatch existed because the database layer and response layer independently decided whether featured listings should be prioritized. Centralizing that decision prevents the two layers from drifting again.
What are the relevant issues?
No linked issue. This was found while auditing the current listing query and response ordering paths. Existing open issues and pull requests were checked for overlap before implementation.
Screenshots (if appropriate)
Not applicable; this is an API ordering correction with no visual layout changes.
Summary by CodeRabbit