Only display last 28 days on stats page (excluding current day)
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Models\Hentai;
|
use App\Models\Hentai;
|
||||||
use App\Models\PopularMonthly;
|
use App\Models\PopularMonthly;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
@@ -46,6 +47,8 @@ class HentaiApiController extends Controller
|
|||||||
// Cache for 60 minutes
|
// Cache for 60 minutes
|
||||||
$data = Cache::remember('api_monthly_views', now()->addMinutes(60), function () {
|
$data = Cache::remember('api_monthly_views', now()->addMinutes(60), function () {
|
||||||
return PopularMonthly::selectRaw('DATE(created_at) as date, COUNT(*) as count')
|
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')
|
->groupBy('date')
|
||||||
->orderBy('date', 'asc')
|
->orderBy('date', 'asc')
|
||||||
->get();
|
->get();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ window.axios.get('/v1/monthly-views').then(function (response) {
|
|||||||
plugins: {
|
plugins: {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: 'Views the last 30 days',
|
text: 'Views the last 28 days',
|
||||||
font: {
|
font: {
|
||||||
size: 18
|
size: 18
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user