mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Group metric points into intervals of 30 seconds
This commit is contained in:
parent
c9baa103dd
commit
55002bb4b4
@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Presenters\MetricPointPresenter;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
@ -88,6 +89,21 @@ class MetricPoint extends Model implements HasPresenter
|
||||
return round((float) $value, $this->metric->places);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the created at value into intervals of 30 seconds.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCreatedAtAttribute($value)
|
||||
{
|
||||
$timestamp = $value->format('U');
|
||||
$timestamp = 30 * round($timestamp / 30);
|
||||
|
||||
return Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the presenter class.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user