refactor: send immediate Traefik version notifications instead of delayed aggregation

Move notification logic from NotifyOutdatedTraefikServersJob into CheckTraefikVersionForServerJob to send immediate notifications when outdated Traefik is detected. This is more suitable for cloud environments with thousands of servers.

Changes:
- CheckTraefikVersionForServerJob now sends notifications immediately after detecting outdated Traefik
- Remove NotifyOutdatedTraefikServersJob (no longer needed)
- Remove delay calculation logic from CheckTraefikVersionJob
- Update tests to reflect new immediate notification pattern

Trade-offs:
- Pro: Faster notifications (immediate alerts)
- Pro: Simpler codebase (removed complex delay calculation)
- Pro: Better scalability for thousands of servers
- Con: Teams may receive multiple notifications if they have many outdated servers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-18 12:30:50 +01:00
parent 0a62739b11
commit 50d55a9509
5 changed files with 56 additions and 261 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Jobs;
use App\Models\Server;
use App\Notifications\Server\TraefikVersionOutdated;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@@ -126,7 +127,7 @@ class CheckTraefikVersionForServerJob implements ShouldQueue
}
/**
* Store outdated information in database.
* Store outdated information in database and send immediate notification.
*/
private function storeOutdatedInfo(string $current, string $latest, string $type, ?string $upgradeTarget = null, ?array $newerBranchInfo = null): void
{
@@ -149,5 +150,24 @@ class CheckTraefikVersionForServerJob implements ShouldQueue
}
$this->server->update(['traefik_outdated_info' => $outdatedInfo]);
// Send immediate notification to the team
$this->sendNotification($outdatedInfo);
}
/**
* Send notification to team about outdated Traefik.
*/
private function sendNotification(array $outdatedInfo): void
{
// Attach the outdated info as a dynamic property for the notification
$this->server->outdatedInfo = $outdatedInfo;
// Get the team and send notification
$team = $this->server->team()->first();
if ($team) {
$team->notify(new TraefikVersionOutdated(collect([$this->server])));
}
}
}