From 900faa3eebafbf88ad45bd2bfa46e7695fc5fe5b Mon Sep 17 00:00:00 2001 From: codex Date: Sat, 24 Oct 2026 01:50:20 +0800 Subject: [PATCH] fix(admin): include all tasks in overview --- web/app/Services/Cloud/CloudAdminOverviewService.php | 3 +-- web/tests/AdminOverviewContractTest.php | 4 ++++ web/tests/AdminOverviewServiceTest.php | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/web/app/Services/Cloud/CloudAdminOverviewService.php b/web/app/Services/Cloud/CloudAdminOverviewService.php index 07c788a1..f3e67fc9 100644 --- a/web/app/Services/Cloud/CloudAdminOverviewService.php +++ b/web/app/Services/Cloud/CloudAdminOverviewService.php @@ -163,8 +163,7 @@ final class CloudAdminOverviewService private static function jobs(int $now, int $todayStart, int $tomorrow): array { $dayAgo = $now - self::DAY; - $row = CloudJob::where('kind', 'create') - ->whereNotNull('order_id') + $row = CloudJob::query() ->where(function ($query) use ($dayAgo) { $query->where('phase', '<>', 'terminal') ->orWhere(function ($failed) use ($dayAgo) { diff --git a/web/tests/AdminOverviewContractTest.php b/web/tests/AdminOverviewContractTest.php index f112ab62..747b3536 100644 --- a/web/tests/AdminOverviewContractTest.php +++ b/web/tests/AdminOverviewContractTest.php @@ -65,6 +65,10 @@ $assert(str_contains($service, "where('status', 'paid')") && str_contains($service, "modify('+1 day')"), 'Financial, instance and job overview boundaries are incomplete.'); +$assert(str_contains($service, '$row = CloudJob::query()') + && str_contains($service, '$today = CloudJob::where(\'kind\', \'create\')'), + 'Operational task cards must cover every task while business-flow totals remain provisioning-only.'); + $assert(str_contains($service, "foreach (\$window['trend'] as \$index => \$day)") && substr_count($service, 'CloudInvoice::where') <= 3, 'Revenue trend must use bounded aggregate queries rather than one query per day.'); diff --git a/web/tests/AdminOverviewServiceTest.php b/web/tests/AdminOverviewServiceTest.php index 49913ca7..1276e130 100644 --- a/web/tests/AdminOverviewServiceTest.php +++ b/web/tests/AdminOverviewServiceTest.php @@ -99,6 +99,10 @@ Capsule::table('cloud_jobs')->insert([ 'outcome' => null, 'effect_resolution' => 'not_applicable', 'terminal_at' => null, 'status' => 'running', 'created_at' => $today + 20, 'updated_at' => $now], + ['order_id' => null, 'kind' => 'rescue', 'phase' => 'terminal', + 'outcome' => 'failed', 'effect_resolution' => 'unknown', + 'terminal_at' => $now - 25, 'status' => 'failed', + 'created_at' => $today + 25, 'updated_at' => $now], ['order_id' => 2, 'kind' => 'create', 'phase' => 'terminal', 'outcome' => 'failed', 'effect_resolution' => 'unknown', 'terminal_at' => $now - 30, 'status' => 'failed', @@ -176,13 +180,13 @@ $assert($overview['instances']['managed'] === 4 && $overview['instances']['expiring_7d'] === 1 && $overview['instances']['grace'] === 1, 'Instance lifecycle aggregation is incorrect.'); -$assert($overview['jobs']['active'] === 1 - && $overview['jobs']['unresolved_effect'] === 2 - && $overview['jobs']['failed_24h'] === 3 +$assert($overview['jobs']['active'] === 2 + && $overview['jobs']['unresolved_effect'] === 3 + && $overview['jobs']['failed_24h'] === 4 && $overview['jobs']['today_total'] === 5 && $overview['jobs']['today_succeeded'] === 2 && $overview['jobs']['today_failed'] === 3, - 'Job aggregation must use terminal time and exclude lifecycle-only work.'); + 'Global job aggregation must include non-provisioning work while today totals remain provisioning-only.'); $assert($overview['attention_total'] === $overview['jobs']['unresolved_effect'] + $overview['jobs']['failed_24h'] + $overview['instances']['network_attention']