mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Merge pull request #2970 from JordyvanDortmont/fix_trailing_default_metric_points
Fix trailing default metric points
This commit is contained in:
commit
5e47b68edc
@ -61,11 +61,19 @@ class MetricRepository
|
|||||||
{
|
{
|
||||||
$dateTime = $this->dates->make();
|
$dateTime = $this->dates->make();
|
||||||
$pointKey = $dateTime->format('Y-m-d H:i');
|
$pointKey = $dateTime->format('Y-m-d H:i');
|
||||||
$points = $this->repository->getPointsSinceMinutes($metric, 60)->pluck('value', 'key')->take(60);
|
$nrOfMinutes = 61;
|
||||||
|
$points = $this->repository->getPointsSinceMinutes($metric, $nrOfMinutes + $metric->threshold)->pluck('value', 'key')->take(-$nrOfMinutes);
|
||||||
|
|
||||||
for ($i = 0; $i <= 60; $i++) {
|
$timeframe = $nrOfMinutes;
|
||||||
|
for ($i = 0; $i < $timeframe; $i++) {
|
||||||
if (!$points->has($pointKey)) {
|
if (!$points->has($pointKey)) {
|
||||||
|
if ($i >= $metric->threshold) {
|
||||||
$points->put($pointKey, $metric->default_value);
|
$points->put($pointKey, $metric->default_value);
|
||||||
|
} else {
|
||||||
|
// The point not found is still within the threshold, so it is ignored and
|
||||||
|
// the timeframe is shifted by one minute
|
||||||
|
$timeframe++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i');
|
$pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user