Only display last 28 days on stats page (excluding current day)

This commit is contained in:
2025-10-23 21:13:07 +02:00
parent 50d8704560
commit 36f0126a21
2 changed files with 4 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Models\Hentai;
use App\Models\PopularMonthly;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use App\Http\Controllers\Controller;
@@ -46,6 +47,8 @@ class HentaiApiController extends Controller
// Cache for 60 minutes
$data = Cache::remember('api_monthly_views', now()->addMinutes(60), function () {
return PopularMonthly::selectRaw('DATE(created_at) as date, COUNT(*) as count')
->whereDate('created_at', '<', Carbon::today())
->whereDate('created_at', '>=', Carbon::today()->subDays(28))
->groupBy('date')
->orderBy('date', 'asc')
->get();