-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDataImporterService.php
80 lines (73 loc) · 2.93 KB
/
DataImporterService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
namespace App\Services;
use App\Jobs\BeamDataImporterJob;
use App\Jobs\BerylDataImporterJob;
use App\Jobs\BinBinDataImporterJob;
use App\Jobs\BirdDataImporterJob;
use App\Jobs\BitMobilityDataImporterJob;
use App\Jobs\BoltDataImporterJob;
use App\Jobs\DocomoDataImporterJob;
use App\Jobs\DottDataImporterJob;
use App\Jobs\HopDataImporterJob;
use App\Jobs\HoppDataImporterJob;
use App\Jobs\HulajDataImporterJob;
use App\Jobs\LimeDataImporterJob;
use App\Jobs\LinkDataImporterJob;
use App\Jobs\NeuronDataImporterJob;
use App\Jobs\QuickDataImporterJob;
use App\Jobs\RydeDataImporterJob;
use App\Jobs\SixtDataImporterJob;
use App\Jobs\SpinDataImporterJob;
use App\Jobs\TierDataImporterJob;
use App\Jobs\UrentDataImporterJob;
use App\Jobs\VeoDataImporterJob;
use App\Jobs\VoiDataImporterJob;
use App\Jobs\WheeMoveDataImporterJob;
use App\Jobs\WindDataImporterJob;
use App\Jobs\ZwingsDataImporterJob;
use App\Models\ImportInfo;
use Illuminate\Support\Facades\Bus;
class DataImporterService
{
private int $importInfoId;
public function run(string $whoRunsIt = "admin"): void
{
$importInfo = ImportInfo::query()->create([
"who_runs_it" => $whoRunsIt,
"status" => "running",
]);
$this->importInfoId = $importInfo->id;
Bus::batch([
new BeamDataImporterJob($this->importInfoId),
new BerylDataImporterJob($this->importInfoId),
new BinBinDataImporterJob($this->importInfoId),
new BirdDataImporterJob($this->importInfoId),
new BitMobilityDataImporterJob($this->importInfoId),
new BoltDataImporterJob($this->importInfoId),
new DottDataImporterJob($this->importInfoId),
new HulajDataImporterJob($this->importInfoId),
new LimeDataImporterJob($this->importInfoId),
new HoppDataImporterJob($this->importInfoId),
new LinkDataImporterJob($this->importInfoId),
new NeuronDataImporterJob($this->importInfoId),
new DocomoDataImporterJob($this->importInfoId),
new QuickDataImporterJob($this->importInfoId),
new RydeDataImporterJob($this->importInfoId),
new SpinDataImporterJob($this->importInfoId),
new TierDataImporterJob($this->importInfoId),
new UrentDataImporterJob($this->importInfoId),
new VoiDataImporterJob($this->importInfoId),
new VeoDataImporterJob($this->importInfoId),
new WindDataImporterJob($this->importInfoId),
new WheeMoveDataImporterJob($this->importInfoId),
new HopDataImporterJob($this->importInfoId),
new ZwingsDataImporterJob($this->importInfoId),
new SixtDataImporterJob($this->importInfoId),
])->finally(function (): void {
ImportInfo::query()->where("id", $this->importInfoId)->update([
"status" => "finished",
]);
})->dispatch();
}
}