Last hour of metric points
This commit is contained in:
@@ -43,6 +43,27 @@ class MetricRepository
|
||||
$this->dateTimeZone = SettingFacade::get('app_timezone');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all points as an array, for the last hour.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listPointsLastHour(Metric $metric)
|
||||
{
|
||||
$dateTime = (new Date())->setTimezone($this->dateTimeZone);
|
||||
$points = [];
|
||||
|
||||
$pointKey = $dateTime->format('H:i');
|
||||
for ($i = 0; $i <= 60; $i++) {
|
||||
$points[$pointKey] = $this->repository->getPointsLastHour($metric, 0, $i);
|
||||
$pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('H:i');
|
||||
}
|
||||
|
||||
return array_reverse($points);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all points as an array, by x hours.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user