Replace importer with AJAX powered; better error handling #443 (#447)

* Replace importer with AJAX powered; better error handling #443

* Formatting

* Fix command line importer
This commit is contained in:
Nabeel S
2019-12-02 09:57:35 -05:00
committed by GitHub
parent 50dc79bc8d
commit 68eff40753
31 changed files with 544 additions and 354 deletions
@@ -7,12 +7,30 @@ use Modules\Installer\Services\Importer\BaseImporter;
class FlightImporter extends BaseImporter
{
protected $table = 'schedules';
public function run($start = 0)
{
$this->comment('--- FLIGHT SCHEDULE IMPORT ---');
$fields = [
'id',
'code',
'flightnum',
'depicao',
'arricao',
'route',
'distance',
'flightlevel',
'deptime',
'arrtime',
'flightttime',
'notes',
'enabled',
];
$count = 0;
foreach ($this->db->readRows('schedules', $start) as $row) {
foreach ($this->db->readRows($this->table, $start, $fields) as $row) {
$airline_id = $this->idMapper->getMapping('airlines', $row->code);
$flight_num = trim($row->flightnum);
@@ -32,7 +50,8 @@ class FlightImporter extends BaseImporter
try {
$w = ['airline_id' => $airline_id, 'flight_number' => $flight_num];
$flight = Flight::updateOrCreate($w, $attrs);
// $flight = Flight::updateOrCreate($w, $attrs);
$flight = Flight::create(array_merge($w, $attrs));
} catch (\Exception $e) {
//$this->error($e);
}