From 7dd94bd21c9f51f465a7170b61264c489bf9d92c Mon Sep 17 00:00:00 2001 From: Jordy van Dortmont Date: Fri, 6 Apr 2018 00:57:51 +0200 Subject: [PATCH] Fix metric point counting within threshold --- .../Commands/Metric/CreateMetricPointCommandHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php b/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php index 4e065de715fe..8fdbe1ca21c6 100644 --- a/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php +++ b/app/Bus/Handlers/Commands/Metric/CreateMetricPointCommandHandler.php @@ -79,7 +79,7 @@ public function handle(CreateMetricPointCommand $command) */ 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;