fix(metrics): address code review feedback for LTTB downsampling

- Wrap return values in collect() to maintain Collection compatibility
- Add comment explaining threshold <= 2 prevents division by zero
- Refactor tests to use actual Server model method via reflection
- Use seeded mt_rand() for reproducible test results

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-12-28 13:39:43 +01:00
parent f199b6bfc4
commit 0e9dbc3625
2 changed files with 28 additions and 78 deletions

View File

@@ -691,7 +691,7 @@ $schema://$host {
$metrics = $this->downsampleLTTB($metrics, 1000);
}
return $metrics;
return collect($metrics);
}
}
@@ -720,7 +720,7 @@ $schema://$host {
$metrics = $this->downsampleLTTB($metrics, 1000);
}
return $metrics;
return collect($metrics);
}
}
@@ -736,6 +736,8 @@ $schema://$host {
{
$dataLength = count($data);
// Return unchanged if threshold >= data length, or if threshold <= 2
// (threshold <= 2 would cause division by zero in bucket calculation)
if ($threshold >= $dataLength || $threshold <= 2) {
return $data;
}