mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Fix MetricPoint changes
This commit is contained in:
parent
db627f6e86
commit
3e5dc6a3f9
@ -14,9 +14,17 @@ namespace CachetHQ\Cachet\Models;
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Presenters\MetricPointPresenter;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
/**
|
||||
* This is the metric point model class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Joseph Cohen <joe@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class MetricPoint extends Model implements HasPresenter
|
||||
{
|
||||
use ValidatingTrait;
|
||||
@ -102,7 +110,9 @@ class MetricPoint extends Model implements HasPresenter
|
||||
return;
|
||||
}
|
||||
|
||||
$createdAt = Carbon::parse($createdAt);
|
||||
if (!$createdAt instanceof DateTime) {
|
||||
$createdAt = Carbon::parse($createdAt);
|
||||
}
|
||||
|
||||
$timestamp = $createdAt->format('U');
|
||||
$timestamp = 30 * round($timestamp / 30);
|
||||
|
@ -69,7 +69,7 @@ class MetricPointTest extends AbstractApiTestCase
|
||||
$this->beUser();
|
||||
|
||||
$metric = factory(Metric::class)->create();
|
||||
$timestamp = 1434369116;
|
||||
$timestamp = strtotime('now');
|
||||
$metricPoint = factory(MetricPoint::class)->make([
|
||||
'metric_id' => $metric->id,
|
||||
]);
|
||||
@ -81,7 +81,7 @@ class MetricPointTest extends AbstractApiTestCase
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonFragment([
|
||||
'value' => $metricPoint->value,
|
||||
'created_at' => date('Y-m-d H:i:00', 1434369116),
|
||||
'created_at' => date('Y-m-d H:i:s', $timestamp),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user