From b285a1d27d05073d7b54a6fea786d31e6ee64dba Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 13 Apr 2026 13:18:47 +0200 Subject: [PATCH] Remove internals from public status page --- app/Http/Controllers/StatusPageController.php | 8 +-- app/Services/SiteStatusService.php | 57 ++++++++++++++++++- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/StatusPageController.php b/app/Http/Controllers/StatusPageController.php index 3dcdb1922..09aaf70c1 100644 --- a/app/Http/Controllers/StatusPageController.php +++ b/app/Http/Controllers/StatusPageController.php @@ -20,10 +20,10 @@ class StatusPageController extends BasePageController */ public function showStatusPage(): View { - $services = $this->siteStatusService->getAllStatuses(); - $overall = $this->siteStatusService->getOverallStatus(); - $activeIncidents = $this->siteStatusService->getActiveIncidents(); - $recentResolved = $this->siteStatusService->getRecentResolvedIncidents(30); + $services = $this->siteStatusService->getPublicEnabledServices(); + $overall = $this->siteStatusService->getOverallPublicStatus(); + $activeIncidents = $this->siteStatusService->getActiveIncidentsForPublic(); + $recentResolved = $this->siteStatusService->getRecentResolvedIncidentsForPublic(30); $groupedResolved = $recentResolved->groupBy(function ($incident) { return $incident->resolved_at?->format('Y-m-d') ?? 'unknown'; diff --git a/app/Services/SiteStatusService.php b/app/Services/SiteStatusService.php index 773fe275d..7ff0c8256 100644 --- a/app/Services/SiteStatusService.php +++ b/app/Services/SiteStatusService.php @@ -57,8 +57,34 @@ class SiteStatusService public function getOverallStatus(): ServiceStatusEnum { - $services = $this->getEnabledServices(); + return $this->aggregateWorstStatus($this->getEnabledServices()); + } + /** + * Enabled HTTP endpoint rows only (excludes internal infrastructure probes from the public status page). + * + * @return \Illuminate\Database\Eloquent\Collection + */ + public function getPublicEnabledServices(): \Illuminate\Database\Eloquent\Collection + { + return ServiceStatus::query() + ->where('is_enabled', true) + ->where('check_type', 'http') + ->orderBy('sort_order') + ->orderBy('id') + ->get(); + } + + public function getOverallPublicStatus(): ServiceStatusEnum + { + return $this->aggregateWorstStatus($this->getPublicEnabledServices()); + } + + /** + * @param \Illuminate\Database\Eloquent\Collection $services + */ + private function aggregateWorstStatus(\Illuminate\Database\Eloquent\Collection $services): ServiceStatusEnum + { if ($services->isEmpty()) { return ServiceStatusEnum::Operational; } @@ -87,6 +113,18 @@ class SiteStatusService ->get(); } + /** + * Active incidents that affect at least one public (HTTP) service — hides internal probe-only outages. + * + * @return \Illuminate\Database\Eloquent\Collection + */ + public function getActiveIncidentsForPublic(): \Illuminate\Database\Eloquent\Collection + { + return $this->getActiveIncidents() + ->filter(fn (ServiceIncident $incident): bool => $this->incidentTouchesPublicService($incident)) + ->values(); + } + /** * @return \Illuminate\Database\Eloquent\Collection */ @@ -103,6 +141,23 @@ class SiteStatusService ->get(); } + /** + * @return \Illuminate\Database\Eloquent\Collection + */ + public function getRecentResolvedIncidentsForPublic(int $days = 30): \Illuminate\Database\Eloquent\Collection + { + return $this->getRecentResolvedIncidents($days) + ->filter(fn (ServiceIncident $incident): bool => $this->incidentTouchesPublicService($incident)) + ->values(); + } + + private function incidentTouchesPublicService(ServiceIncident $incident): bool + { + return $incident->services->contains( + fn (ServiceStatus $service): bool => $service->check_type === 'http' + ); + } + /** * Recalculate uptime percentage for a service over a rolling window. *