Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #3842 #4026

Merged
merged 1 commit into from
Aug 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/Repositories/Metric/MetricRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,23 @@ public function listPointsLastHour(Metric $metric)
$points = $this->repository->getPointsSinceMinutes($metric, $nrOfMinutes + $metric->threshold)->pluck('value', 'key')->take(-$nrOfMinutes);

$timeframe = $nrOfMinutes;

//Settings counter for minutes without data
$minutesWithNoData = 0;

for ($i = 0; $i < $timeframe; $i++) {
if (!$points->has($pointKey)) {
if ($i >= $metric->threshold) {
$points->put($pointKey, $metric->default_value);
//We put default value as metric, so we can reset counter for minutes without data
$minutesWithNoData = 0;
} else {
// The point not found is still within the threshold, so it is ignored and
// the timeframe is shifted by one minute
$timeframe++;
//We didn't find any data, but threshold is not meet yet so we just adding to counter
$minutesWithNoData++;
}
} else {
//We found data within this threshold, zeroing counter
$minutesWithNoData = 0;
}

$pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i');
Expand Down