Files
ghassanandClaude Opus 4.7 133ab6e623 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]>
2026-10-21 10:06:54 +03:00

203 lines
6.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@extends('layouts.app')
@section('title', 'Trending Videos | ' . config('app.name'))
@section('extra_styles')
<style>
.trending-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 1px solid var(--border-color);
}
.trending-header h1 {
font-size: 24px;
font-weight: 600;
margin: 0;
display: flex;
align-items: center;
gap: 10px;
}
.trending-icon {
color: #f00;
font-size: 28px;
}
.trending-filters {
display: flex;
gap: 8px;
margin-left: auto;
}
.trending-filters a {
padding: 6px 14px;
border-radius: 18px;
font-size: 13px;
font-weight: 500;
text-decoration: none;
background: var(--bg-secondary);
color: var(--text-secondary);
transition: all 0.2s;
}
.trending-filters a:hover {
background: var(--bg-tertiary);
color: var(--text-primary);
}
.trending-filters a.active {
background: var(--accent-color);
color: white;
}
.trending-badge {
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.85);
color: white;
padding: 3px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
display: flex;
align-items: center;
gap: 4px;
}
.trending-badge i { color: #f00; }
.yt-video-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
.yt-video-card { cursor: pointer; }
.yt-video-thumb {
position: relative;
aspect-ratio: 16/9;
border-radius: 12px;
overflow: hidden;
background: #1a1a1a;
}
.yt-video-thumb img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.2s;
}
.yt-video-card:hover .yt-video-thumb img { transform: scale(1.05); }
.yt-video-duration {
position: absolute;
bottom: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.85);
color: white;
padding: 3px 6px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
}
.yt-video-meta {
display: flex;
gap: 12px;
padding-top: 12px;
}
.yt-video-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
object-fit: cover;
flex-shrink: 0;
}
.yt-video-info {
flex: 1;
min-width: 0;
}
.yt-video-title {
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
margin: 0 0 6px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
line-height: 1.3;
}
.yt-video-channel {
font-size: 13px;
color: var(--text-secondary);
margin-bottom: 4px;
}
.yt-video-channel a {
color: var(--text-secondary);
text-decoration: none;
}
.yt-video-stats { font-size: 13px; color: var(--text-secondary); }
@media (max-width: 1200px) {
.yt-video-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
.trending-header { flex-wrap: wrap; }
.trending-filters { margin-left: 0; width: 100%; margin-top: 12px; }
.yt-video-grid { grid-template-columns: 1fr; gap: 20px; }
}
.empty-trending {
text-align: center;
padding: 60px 20px;
color: var(--text-secondary);
}
.empty-trending i { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-trending h3 { font-size: 20px; color: var(--text-primary); margin-bottom: 8px; }
</style>
@endsection
@section('content')
<div class="trending-header">
<h1><i class="bi bi-fire trending-icon"></i> Trending</h1>
<div class="trending-filters">
{{-- Hours line up with the labels: 24 = Today, 168 = This Week
(7×24), 720 = This Month (30×24). The old 24/48/168 trio
claimed Month but silently showed Week data because the
controller clamped the max to 168. --}}
<a href="{{ route('videos.trending', ['hours' => 24]) }}" class="{{ $hours == 24 ? 'active' : '' }}" @if($hours == 24) aria-current="page"@endif>Today</a>
<a href="{{ route('videos.trending', ['hours' => 168]) }}" class="{{ $hours == 168 ? 'active' : '' }}" @if($hours == 168) aria-current="page"@endif>This Week</a>
<a href="{{ route('videos.trending', ['hours' => 720]) }}" class="{{ $hours == 720 ? 'active' : '' }}" @if($hours == 720) aria-current="page"@endif>This Month</a>
</div>
</div>
@if($videos->isEmpty())
<div class="empty-trending">
<i class="bi bi-play-circle"></i>
<h3>No trending videos yet</h3>
<p>Videos with high engagement will appear here</p>
</div>
@else
<div class="yt-video-grid">
@foreach($videos as $video)
<x-video-card :video="$video" />
@endforeach
</div>
@endif
@endsection