Updated seeder command to include groups and new incident content.

This commit is contained in:
James Brooks
2015-08-15 11:56:19 +01:00
parent 905445d0ca
commit a294b34d64
+38 -7
View File
@@ -12,6 +12,7 @@
namespace CachetHQ\Cachet\Console\Commands; namespace CachetHQ\Cachet\Console\Commands;
use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\Metric; use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint; use CachetHQ\Cachet\Models\MetricPoint;
@@ -49,6 +50,7 @@ class DemoSeederCommand extends Command
*/ */
public function fire() public function fire()
{ {
$this->seedComponentGroups();
$this->seedComponents(); $this->seedComponents();
$this->seedIncidents(); $this->seedIncidents();
$this->seedMetricPoints(); $this->seedMetricPoints();
@@ -57,6 +59,27 @@ class DemoSeederCommand extends Command
$this->seedUsers(); $this->seedUsers();
} }
/**
* Seed the component groups table.
*
* @return void
*/
protected function seedComponentGroups()
{
$defaultGroups = [
[
'name' => 'Websites',
'order' => 1,
],
];
ComponentGroup::truncate();
foreach ($defaultGroups as $group) {
ComponentGroup::create($group);
}
}
/** /**
* Seed the components table. * Seed the components table.
* *
@@ -77,21 +100,21 @@ class DemoSeederCommand extends Command
'description' => 'Kindly powered by Readme.io', 'description' => 'Kindly powered by Readme.io',
'status' => 1, 'status' => 1,
'order' => 0, 'order' => 0,
'group_id' => 0, 'group_id' => 1,
'link' => 'https://docs.cachethq.io', 'link' => 'https://docs.cachethq.io',
], [ ], [
'name' => 'Website', 'name' => 'Website',
'description' => '', 'description' => '',
'status' => 1, 'status' => 1,
'order' => 0, 'order' => 0,
'group_id' => 0, 'group_id' => 1,
'link' => 'https://cachethq.io', 'link' => 'https://cachethq.io',
], [ ], [
'name' => 'Blog', 'name' => 'Blog',
'description' => 'The Cachet Blog.', 'description' => 'The Cachet Blog.',
'status' => 1, 'status' => 1,
'order' => 0, 'order' => 0,
'group_id' => 0, 'group_id' => 1,
'link' => 'https://blog.cachethq.io', 'link' => 'https://blog.cachethq.io',
], ],
]; ];
@@ -113,7 +136,7 @@ class DemoSeederCommand extends Command
$defaultIncidents = [ $defaultIncidents = [
[ [
'name' => 'Awesome', 'name' => 'Awesome',
'message' => 'We totally nailed the fix :smile:', 'message' => ':+1: We totally nailed the fix.',
'status' => 4, 'status' => 4,
'component_id' => 0, 'component_id' => 0,
'scheduled_at' => null, 'scheduled_at' => null,
@@ -121,7 +144,7 @@ class DemoSeederCommand extends Command
], ],
[ [
'name' => 'Monitoring the fix', 'name' => 'Monitoring the fix',
'message' => "We're checking that our fix will first work.", 'message' => ":ship: We've deployed a fix.",
'status' => 3, 'status' => 3,
'component_id' => 0, 'component_id' => 0,
'scheduled_at' => null, 'scheduled_at' => null,
@@ -129,7 +152,7 @@ class DemoSeederCommand extends Command
], ],
[ [
'name' => 'Update', 'name' => 'Update',
'message' => "We've found the problem, so we're looking at it.", 'message' => "We've identified the problem. Our engineers are currently looking at it.",
'status' => 2, 'status' => 2,
'component_id' => 0, 'component_id' => 0,
'scheduled_at' => null, 'scheduled_at' => null,
@@ -137,12 +160,20 @@ class DemoSeederCommand extends Command
], ],
[ [
'name' => 'Test Incident', 'name' => 'Test Incident',
'message' => 'Something went wrong, oh noes.', 'message' => 'Something went wrong, with something or another.',
'status' => 1, 'status' => 1,
'component_id' => 0, 'component_id' => 0,
'scheduled_at' => null, 'scheduled_at' => null,
'visible' => 1, 'visible' => 1,
], ],
[
'name' => 'Investigating the API',
'message' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.',
'status' => 1,
'component_id' => 1,
'scheduled_at' => null,
'visible' => 1,
],
]; ];
Incident::truncate(); Incident::truncate();