Skip to content

fix(homepage): video order by publish date and no hero/category duplicate#219

Open
kubo6472 wants to merge 1 commit intomainfrom
cursor/fix-homepage-video-order-dedupe-4309
Open

fix(homepage): video order by publish date and no hero/category duplicate#219
kubo6472 wants to merge 1 commit intomainfrom
cursor/fix-homepage-video-order-dedupe-4309

Conversation

@kubo6472
Copy link
Copy Markdown
Member

@kubo6472 kubo6472 commented May 9, 2026

Summary

The public homepage hero (top_video) used a client-side sort that did not always match how videos were ordered in the API or placement logic, and it could show the same clip again in a category block when a pinned/legacy featured slot left the globally newest video in a category row.

Changes

  • packages/shared/src/homepagePlacementSort.ts — Shared placementTimestampMs and compareVideosNewestFirst (prefer published_at, else upload_date, stable id tie-break) so the web app and Worker agree on recency.
  • packages/api/src/homepagePlacement.ts — Uses the shared comparators instead of duplicating logic.
  • packages/api/src/index.ts/api/videos: order by the same publish-vs-upload rule in SQL; collapse duplicate rows from the category assignment LEFT JOIN (prefer a row with a category when merging); final list order uses compareVideosNewestFirst.
  • packages/web/composables/useHomepageLayout.ts — Sort from deduped Map values with compareVideosNewestFirst; treat the hero id as reserved so it is omitted from featured_row sources and category visible/overflow lists.

Testing

  • npx tsx --test ./test/homepage-placement.test.ts (pass)
  • npm run typecheck in @vmp/api (pass)

Full npm test --workspace=@vmp/api still reports unrelated failures in pills and segment analytics suites (pre-existing in this environment).

Open in Web Open in Cursor 

- Add shared placementTimestampMs/compareVideosNewestFirst for API and web
- Sort public /api/videos by published_at then upload_date; dedupe multi-category JOIN rows
- Build top_video from deduped list; exclude hero id from featured_row and category blocks

Co-authored-by: Jakub Doboš <kubo6472@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@kubo6472 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 35 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6fb3dd0-be0d-4c37-8aa8-2371d1ef7251

📥 Commits

Reviewing files that changed from the base of the PR and between 302167b and b5b1634.

📒 Files selected for processing (5)
  • packages/api/src/homepagePlacement.ts
  • packages/api/src/index.ts
  • packages/shared/src/homepagePlacementSort.ts
  • packages/shared/src/index.ts
  • packages/web/composables/useHomepageLayout.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-homepage-video-order-dedupe-4309

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.

@kubo6472 kubo6472 marked this pull request as ready for review May 9, 2026 21:54
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