mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user