Skip to content

Commit

Permalink
fix: #273 fix metrics validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-shulha committed Nov 22, 2024
1 parent c902233 commit 899121f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api-nodes/Http/Controllers/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ApiNodes\Http\Controllers;

use App\Models\DeploymentData\Caddy;
use App\Models\DeploymentData\Process;
use App\Models\Node;
use App\Services\Metrics;
Expand Down Expand Up @@ -57,8 +58,14 @@ public function __invoke(Request $request, Logger $log, Node $node)

$ruleIds = $processes->mapWithKeys(function (Process $process) {
$caddyIds = collect($process->caddy)->pluck('id');
$redirectRuleIds = collect($process->redirectRules)->pluck('id');
$rewriteRuleIds = collect($process->rewriteRules)->pluck('id');
$redirectRuleIds = collect($process)
->flatMap(fn (Process $process) => collect($process->caddy)->flatMap(fn (Caddy $caddy) => collect($caddy->redirectRules)->pluck('id')))
->unique()
->toArray();
$rewriteRuleIds = collect($process)
->flatMap(fn (Process $process) => collect($process->caddy)->flatMap(fn (Caddy $caddy) => collect($caddy->rewriteRules)->pluck('id')))
->unique()
->toArray();

$ruleIds = $caddyIds->merge($redirectRuleIds)->merge($rewriteRuleIds)->toArray();

Expand Down

0 comments on commit 899121f

Please sign in to comment.