mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Improve seeding of metric points
This commit is contained in:
parent
f98ae4d38e
commit
5de9c94d55
@ -66,16 +66,26 @@ class DemoMetricPointSeederCommand extends Command
|
||||
{
|
||||
MetricPoint::truncate();
|
||||
|
||||
// Generate 11 hours of metric points
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$metricTime = (new DateTime())->sub(new DateInterval('PT'.$i.'H'));
|
||||
$points = [];
|
||||
|
||||
MetricPoint::create([
|
||||
'metric_id' => 1,
|
||||
'value' => random_int(1, 10),
|
||||
'created_at' => $metricTime,
|
||||
'updated_at' => $metricTime,
|
||||
]);
|
||||
// Generate 24 hours of metric points
|
||||
for ($i = 0; $i <= 23; $i++) {
|
||||
for ($j = 0; $j <= 59; $j++) {
|
||||
$this->info("{$i}:{$j}");
|
||||
|
||||
$pointTime = date("Y-m-d {$i}:{$j}:00");
|
||||
|
||||
$points[] = [
|
||||
'metric_id' => 1,
|
||||
'value' => random_int(1, 10),
|
||||
'created_at' => $pointTime,
|
||||
'updated_at' => $pointTime,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_chunk($points, 100) as $chunk) {
|
||||
MetricPoint::insert($chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user