fix(feeds): trending windows 24/168/720, music newest-first, channel popular tiebreak
- Trending: window options are now 24 / 168 / 720 h (Today / This Week / This Month) and the controller snaps the ?hours param to one of those values instead of clamping to [24, 168] — which silently made the "This Month" tab show one-week data. Ranking is pure in-window view count, with likes and newest createdAt as the tiebreaks (not the old weighted sum of views + velocity + recency bonus + likes, which was impossible to reason about and hid videos that genuinely led the window). - Music + /videos?filter=music: previously the branch skipped the latest() call so Eloquent fell back to id ASC and the music tab opened on the oldest uploads. Now both branches share one ->latest() call. - Channel Popular sort: order by views desc, likes desc, created_at desc so two equally-viewed videos no longer flip order between loads. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
1 parent
a25af30700
commit
133ab6e623
3 files changed
+48
-29
No files matched your search
@@ -246,7 +246,14 @@ class UserController extends Controller
|
||||
|
||||
switch ($sort) {
|
||||
case 'popular':
|
||||
$baseQuery->withCount('viewers')->orderByDesc('viewers_count');
|
||||
// Views first, likes as the tiebreak, created_at as the final
|
||||
// tiebreak so two videos with the same view+like counts don't
|
||||
// flip order between page loads.
|
||||
$baseQuery
|
||||
->withCount(['viewers as viewers_count', 'likes as likes_count'])
|
||||
->orderByDesc('viewers_count')
|
||||
->orderByDesc('likes_count')
|
||||
->latest();
|
||||
break;
|
||||
case 'oldest':
|
||||
$baseQuery->oldest();
|
||||
|
||||
Reference in new issue
Block a user