Medowar 1 месяц назад
Родитель
Сommit
3a37ffa47c
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      src/AlertService.php

+ 5 - 3
src/AlertService.php

@@ -6,6 +6,8 @@ namespace App;
 
 final class AlertService
 {
+    private const MAX_EVENTS = 15;
+
     private JsonFile $logStorage;
 
     public function __construct(
@@ -65,14 +67,14 @@ final class AlertService
             'payload' => $payload,
             'deliveries' => $deliveryResults,
         ]);
-        $log['events'] = array_slice($events, 0, 200);
+        $log['events'] = array_slice($events, 0, self::MAX_EVENTS);
         $this->logStorage->write($log);
     }
 
-    public function getRecentEvents(int $limit = 25): array
+    public function getRecentEvents(int $limit = self::MAX_EVENTS): array
     {
         $log = $this->logStorage->read();
-        return array_slice($log['events'] ?? [], 0, $limit);
+        return array_slice($log['events'] ?? [], 0, min($limit, self::MAX_EVENTS));
     }
 
     private function sendWebhooks(array $slot, array $payload): array