This commit is contained in:
DariusIII
2026-04-30 16:45:15 +02:00
parent dba05ec344
commit f98fbba39c
4 changed files with 8 additions and 7 deletions
@@ -11,6 +11,7 @@ use App\Services\SiteStatusService;
use App\Services\SystemMetricsService;
use App\Services\UserStatsService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Carbon;
class AdminPageController extends BasePageController
{
@@ -120,7 +121,7 @@ class AdminPageController extends BasePageController
];
$generatedAt = $payload['generated_at'] ?? now()->toIso8601String();
$generatedAtCarbon = \Illuminate\Support\Carbon::parse($generatedAt);
$generatedAtCarbon = Carbon::parse($generatedAt);
return response()->json([
'success' => true,
+2 -1
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Models;
use App\Services\UserStatsService;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -113,7 +114,7 @@ class UserActivityStat extends Model
* Sums closed days from `user_activity_stats` and today's closed hours
* from `user_activity_stats_hourly`. The current in-progress hour is not
* included here — callers needing live "today" totals should use
* {@see \App\Services\UserStatsService::getSummaryStats()} which layers
* {@see UserStatsService::getSummaryStats()} which layers
* the live tables on top.
*/
public static function getTotalDownloads(int $days = 7): int
@@ -50,7 +50,7 @@ class AdminDashboardAutoRefreshTest extends TestCase
// Auto-refresh interval is preserved.
$this->assertStringContainsString('15 * 60 * 1000', $content);
// The fetch hits the cached JSON endpoint.
$this->assertStringContainsString("this.\$el.dataset.dataUrl", $content);
$this->assertStringContainsString('this.$el.dataset.dataUrl', $content);
// Each tick re-renders headline tiles + registration status + the
// visible "Last refresh" label, not just the deferred widgets.
$this->assertStringContainsString('_renderHeadlineStats(payload.stats)', $content);
@@ -31,13 +31,13 @@ class AdminDashboardSummaryWindowTest extends TestCase
// 7-day window inclusive of today (today-6 .. today).
$this->assertStringContainsString(
"\$weekStart = Carbon::now()->subDays(6)->startOfDay();",
'$weekStart = Carbon::now()->subDays(6)->startOfDay();',
$content,
'Summary window must be the last 7 calendar days inclusive of today.'
);
// Closed days from the daily aggregate, strictly before today.
$this->assertStringContainsString("UserActivityStat::query()", $content);
$this->assertStringContainsString('UserActivityStat::query()', $content);
$this->assertStringContainsString(
"->where('stat_date', '>=', \$weekStart->format('Y-m-d'))",
$content
@@ -88,7 +88,7 @@ class AdminDashboardSummaryWindowTest extends TestCase
// The previous "two-days-ago" boundary that produced the under-reporting
// bug must be gone from getSummaryStats.
$this->assertStringNotContainsString(
"\$twoDaysAgo = Carbon::now()->subDays(2)->startOfDay();",
'$twoDaysAgo = Carbon::now()->subDays(2)->startOfDay();',
$content
);
}
@@ -165,4 +165,3 @@ class AdminDashboardSummaryWindowTest extends TestCase
);
}
}