Fix generation of metrics, no longer sub an extra hour in calculation
This commit is contained in:
@@ -93,7 +93,7 @@ class Metric extends Model implements HasPresenter
|
||||
$dateTimeZone = SettingFacade::get('app_timezone');
|
||||
$dateTime = (new Date())->setTimezone($dateTimeZone)->sub(new DateInterval('PT'.$hour.'H'));
|
||||
|
||||
$hourInterval = $dateTime->sub(new DateInterval('PT'.$hour.'H'))->format('YmdH');
|
||||
$hourInterval = $dateTime->format('YmdH');
|
||||
|
||||
if (Config::get('database.default') === 'mysql') {
|
||||
if (!isset($this->calc_type) || $this->calc_type == self::CALC_SUM) {
|
||||
|
||||
@@ -27,5 +27,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call('SettingsTableSeeder');
|
||||
$this->call('IncidentTableSeeder');
|
||||
$this->call('ComponentTableSeeder');
|
||||
$this->call('MetricTableSeeder');
|
||||
}
|
||||
}
|
||||
|
||||
34
database/seeds/MetricPointSeeder.php
Normal file
34
database/seeds/MetricPointSeeder.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) James Brooks <james@cachethq.io>
|
||||
* (c) Joseph Cohen <joseph.cohen@dinkbit.com>
|
||||
* (c) Graham Campbell <graham@mineuk.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MetricPointSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeding.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
$metric = [
|
||||
'metric_id' => 1,
|
||||
'value' => rand(1, 100),
|
||||
];
|
||||
|
||||
MetricPoint::create($metric);
|
||||
}
|
||||
}
|
||||
44
database/seeds/MetricTableSeeder.php
Normal file
44
database/seeds/MetricTableSeeder.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) James Brooks <james@cachethq.io>
|
||||
* (c) Joseph Cohen <joseph.cohen@dinkbit.com>
|
||||
* (c) Graham Campbell <graham@mineuk.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MetricTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeding.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
$defaultMetrics = [
|
||||
[
|
||||
'name' => 'Demo Metric',
|
||||
'suffix' => 'rnd',
|
||||
'description' => 'Random data points.',
|
||||
'default_value' => 0,
|
||||
'calc_type' => 1,
|
||||
'display_chart' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
Metric::truncate();
|
||||
|
||||
foreach ($defaultMetrics as $metric) {
|
||||
Metric::create($metric);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,10 @@ class SettingsTableSeeder extends Seeder
|
||||
'name' => 'app_analytics_gs',
|
||||
'value' => 'GSN-712462-P',
|
||||
],
|
||||
[
|
||||
'name' => 'display_graphs',
|
||||
'value' => '1',
|
||||
],
|
||||
];
|
||||
|
||||
Setting::truncate();
|
||||
|
||||
Reference in New Issue
Block a user