Skip to content

Capped Featured Bounties to 2 and based on deadline.#1378

Open
RevTpark wants to merge 1 commit into
mainfrom
fix/cap-featured-bounties
Open

Capped Featured Bounties to 2 and based on deadline.#1378
RevTpark wants to merge 1 commit into
mainfrom
fix/cap-featured-bounties

Conversation

@RevTpark

@RevTpark RevTpark commented May 11, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

  • Featured bounties are now capped at 2 and internally sorted by deadline. The bounty that is not featured is thn sorted into the list by deadline.

Where should the reviewer start?

How should this be manually tested?

Any background context you want to provide?

What are the relevant issues?

Screenshots (if appropriate)

Summary by CodeRabbit

  • Bug Fixes
    • Featured listings are now capped at a maximum of 2, with priority given to those with the earliest approaching deadlines. Any ongoing featured listings that exceed this limit will be demoted and lose their featured status. This ensures better visibility and focus on the most urgent, time-sensitive listings available.

Review Change Stack

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
earn Ready Ready Preview May 11, 2026 11:47am

Request Review

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The reorderFeaturedOngoing utility now caps promoted ongoing featured listings to two, sorts both promoted and non-promoted results by deadline time, and explicitly demotes unpromoted featured listings by setting their isFeatured flag to false.

Changes

Featured Listings Reordering

Layer / File(s) Summary
Promotion Capacity Constant
src/features/listings/utils/reorderFeaturedOngoing.ts
MAX_FEATURED_LISTINGS constant is introduced with value 2 to cap promoted ongoing featured listings.
Deadline Time Extraction
src/features/listings/utils/reorderFeaturedOngoing.ts
getDeadlineTime() helper function returns Number.POSITIVE_INFINITY for absent deadlines, otherwise returns the deadline's millisecond timestamp for sorting.
Reordering Pipeline
src/features/listings/utils/reorderFeaturedOngoing.ts
reorderFeaturedOngoing filters and sorts ongoing featured listings, promotes the top two by deadline, excludes promoted items using a Set, demotes remaining featured items by setting isFeatured: false via spread, sorts non-promoted items by deadline, and concatenates promoted with remaining results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Two featured friends now race the clock,
With deadline deadlines as their stock,
The rest get bumped to quiet rest—
The swiftest listings pass the test!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: capping featured listings to 2 and sorting them by deadline, which directly matches the PR objectives and code modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cap-featured-bounties

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.

@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.

🧹 Nitpick comments (1)
src/features/listings/utils/reorderFeaturedOngoing.ts (1)

31-55: ⚡ Quick win

Consider adding JSDoc documentation.

The function now implements three distinct behaviors (capping to 2, sorting by deadline, downgrading excess featured items) that are not immediately obvious from the function name alone. A brief JSDoc comment would help future maintainers understand the intended behavior without reading the implementation.

📝 Suggested JSDoc comment
+/**
+ * Reorders listings to promote up to 2 ongoing featured listings with the earliest deadlines.
+ * All listings are sorted by deadline. Ongoing featured listings beyond the limit are downgraded.
+ */
 export function reorderFeaturedOngoing<T extends MinimalListing>(
   listings: T[],
 ): T[] {
🤖 Prompt for 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.

In `@src/features/listings/utils/reorderFeaturedOngoing.ts` around lines 31 - 55,
Add a JSDoc block above the reorderFeaturedOngoing function documenting its
behavior: state that reorderFeaturedOngoing<T extends MinimalListing>(listings:
T[]): T[] sorts ongoing listings by deadline, promotes up to
MAX_FEATURED_LISTINGS ongoing featured items to the front (preserving sorted
order), and downgrades any additional ongoing featured items (sets isFeatured to
false) before appending them; mention it relies on isOngoingListing and
getDeadlineTime, note it returns a new array and does not mutate original
listing objects except for the created downgraded copies, and include parameter
and return type descriptions and a brief example of expected outcome.
🤖 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.

Nitpick comments:
In `@src/features/listings/utils/reorderFeaturedOngoing.ts`:
- Around line 31-55: Add a JSDoc block above the reorderFeaturedOngoing function
documenting its behavior: state that reorderFeaturedOngoing<T extends
MinimalListing>(listings: T[]): T[] sorts ongoing listings by deadline, promotes
up to MAX_FEATURED_LISTINGS ongoing featured items to the front (preserving
sorted order), and downgrades any additional ongoing featured items (sets
isFeatured to false) before appending them; mention it relies on
isOngoingListing and getDeadlineTime, note it returns a new array and does not
mutate original listing objects except for the created downgraded copies, and
include parameter and return type descriptions and a brief example of expected
outcome.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93292372-04ec-4a82-b916-06cf8dcbcfbc

📥 Commits

Reviewing files that changed from the base of the PR and between 57a24f2 and 75c2134.

📒 Files selected for processing (1)
  • src/features/listings/utils/reorderFeaturedOngoing.ts

@a20hek a20hek closed this Jun 1, 2026
@RevTpark RevTpark reopened this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants