E4 — Channels & Discovery#109
Conversation
…LO-123) Inserts a watch_history self-join between same-channel and FTS passes so viewers get videos that other people who watched this one also watched. Ranks by co-occurrence count, view count, recency. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
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 ignored due to path filters (1)
📒 Files selected for processing (6)
✨ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9b02279f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| FROM watch_history wh1 | ||
| JOIN watch_history wh2 ON wh2.user_id = wh1.user_id AND wh2.video_id != wh1.video_id | ||
| JOIN videos v ON v.id = wh2.video_id | ||
| LEFT JOIN user u ON u.id = v.user_id | ||
| WHERE wh1.video_id = ? |
There was a problem hiding this comment.
Add a video_id index for the new co-watch scan
The new co-watch pass filters on wh1.video_id = ? and then self-joins watch_history, but the existing schema only defines PRIMARY KEY (user_id, video_id) plus idx_watch_history_user_recent (see src/db/migrations/0015_watch_history.sql), so this path has no dedicated leading index on video_id. As watch_history grows, related-video requests will degrade into large scans/high row reads on a hot endpoint, which can materially hurt latency and cost in production; adding an index like (video_id, user_id) for this query shape would avoid that regression.
Useful? React with 👍 / 👎.
Builds on the existing co-watch step in /api/videos/:id/related to finish the E4 scope: - Migration 0019 adds idx_watch_history(video_id) so the co-watch self-join starts from an index seek on the cohort of viewers, instead of scanning the full watch_history table. - Schema mirror picks up watch_history + both indexes so a fresh dev clone starts from the same shape the migrations produce. - Browse-by-topic rail on Home fetches /api/tags top tags and renders them as chips linking to /tag/:slug. Logged-out visitors get the category surface without leaving the home feed; the section hides cleanly when the catalog has no tagged videos yet. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
Closes ALO-123.
Summary
E4 (channel pages, trending feed, search, tags, related videos, up-next queue) was already shipped across earlier tickets (ALO-145/152/153/156, etc). This PR closes out the remaining E4 scope items.
Recommendations — simple co-watch.
/api/videos/:id/relatednow runs awatch_historyself-join between the same-channel pass and the FTS5 pass:Empty watch_history overlap gracefully falls through. KV cache key/TTL unchanged.
Co-watch index (migration 0019). Adds
idx_watch_history(video_id)so the wh1 anchor of the self-join is an index seek instead of a full table scan; otherwise every related-video request scales with total catalog watches.schema.sqlis updated to mirrorwatch_history+ both indexes so a fresh clone starts from the same shape the migrations produce.Browse by topic on Home. New rail under Trending fetches
/api/tags?limit=12and renders chips linking to/tag/:slug. Logged-out visitors get the category surface without leaving the home feed. Hidden cleanly when no tagged videos exist yet so we don't render an empty section.Test plan
npm test— 494/494 pass (co-watch ordering + migration assertions)npm run lint— clean, AI-gateway guard cleannpm run type-check— cleannpm run build— clean/logged-out — Trending → Browse by topic → Start here in that order; tag chips link to/tag/:slug