File: /home/xedaptot/ai.naniguide.com/app/Notifications/System/CacheRefreshFailed.php
<?php
namespace App\Notifications\System;
use App\Notifications\AppNotification;
use Throwable;
/**
* A cache-manifest entry refresh job blew up (timeout, query error, OOM).
* Surfaced to admins because the freshness strip will keep rendering "never"
* (or the default zero) until they see the failure and act on it.
*
* groupKey is per (scope, entry) so repeated failures of the same entry
* collapse into one banner instead of flooding the bell — but two different
* failing entries each get their own banner.
*/
class CacheRefreshFailed extends AppNotification
{
public function __construct(
public string $scope,
public ?string $entry,
public Throwable $exception,
) {}
public function audience(): string { return self::AUDIENCE_ADMINS; }
public function category(): string { return self::CATEGORY_ALERT; }
public function severity(): string { return self::SEVERITY_ERROR; }
public function groupKey(): string
{
return 'cache-refresh-failed:' . $this->scope . ':' . ($this->entry ?? '*');
}
public function toArray(object $notifiable = null): array
{
return [
'title' => 'Cache refresh failed',
'body' => sprintf(
'Entry "%s" on scope "%s" failed: %s — %s',
$this->entry ?? '*all*',
$this->scope,
get_class($this->exception),
$this->exception->getMessage()
),
'meta' => [
'scope' => $this->scope,
'entry' => $this->entry,
'exception' => get_class($this->exception),
'message' => $this->exception->getMessage(),
'trace' => $this->exception->getTraceAsString(),
],
];
}
}