fix(homepage): video order by publish date and no hero/category duplicate#219
fix(homepage): video order by publish date and no hero/category duplicate#219
Conversation
- 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>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 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 |
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— SharedplacementTimestampMsandcompareVideosNewestFirst(preferpublished_at, elseupload_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 assignmentLEFT JOIN(prefer a row with a category when merging); final list order usescompareVideosNewestFirst.packages/web/composables/useHomepageLayout.ts— Sort from dedupedMapvalues withcompareVideosNewestFirst; treat the hero id as reserved so it is omitted fromfeatured_rowsources and category visible/overflow lists.Testing
npx tsx --test ./test/homepage-placement.test.ts(pass)npm run typecheckin@vmp/api(pass)Full
npm test --workspace=@vmp/apistill reports unrelated failures in pills and segment analytics suites (pre-existing in this environment).