Fix metric point counting within threshold

This commit is contained in:
Jordy van Dortmont 2018-04-06 00:57:51 +02:00
parent 3c51e5115a
commit 7dd94bd21c

View File

@ -79,7 +79,7 @@ class CreateMetricPointCommandHandler
*/
protected function findOrCreatePoint(CreateMetricPointCommand $command)
{
$buffer = Carbon::now()->subMinutes($command->metric->threshold);
$buffer = Carbon::now()->subMinutes($command->metric->threshold - 1)->startOfMinute();
if ($point = MetricPoint::where('metric_id', '=', $command->metric->id)->where('value', '=', $command->value)->where('created_at', '>=', $buffer)->first()) {
return $point;