@@ -58,10 +58,11 @@ discard block |
||
| 58 | 58 | //TODO insert a timeout |
| 59 | 59 | //TODO try...catch with destruct |
| 60 | 60 | $companyId = $this->argument('companyId'); |
| 61 | - if (is_numeric($companyId)) |
|
| 62 | - $this->makeForeground(Company::findOrFail($companyId)); |
|
| 63 | - else |
|
| 64 | - $this->syncAll(); |
|
| 61 | + if (is_numeric($companyId)) { |
|
| 62 | + $this->makeForeground(Company::findOrFail($companyId)); |
|
| 63 | + } else { |
|
| 64 | + $this->syncAll(); |
|
| 65 | + } |
|
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | /** |
@@ -74,12 +75,13 @@ discard block |
||
| 74 | 75 | try { |
| 75 | 76 | (new Optimise($company, $this->schedule, $this->laravel))->optimise()->save(); |
| 76 | 77 | $this->info('Optimisation ' . $company->id . ' completed'); |
| 77 | - }catch(OptimiseException $e){ |
|
| 78 | - if($e->isEmpty()) |
|
| 79 | - $this->warn('Company ' . $company->id . ' has no sufficient data'); |
|
| 80 | - else |
|
| 81 | - $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage()); |
|
| 82 | - }catch(\Exception $e) { |
|
| 78 | + } catch(OptimiseException $e){ |
|
| 79 | + if($e->isEmpty()) { |
|
| 80 | + $this->warn('Company ' . $company->id . ' has no sufficient data'); |
|
| 81 | + } else { |
|
| 82 | + $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage()); |
|
| 83 | + } |
|
| 84 | + } catch(\Exception $e) { |
|
| 83 | 85 | $this->error('Error during optimisation of company ' . $company->id .': '. $e->getMessage()); |
| 84 | 86 | } |
| 85 | 87 | } |
@@ -90,13 +92,15 @@ discard block |
||
| 90 | 92 | if ($this->option('background')) { |
| 91 | 93 | \Log::debug(self::BACKGROUND_MOD_MEX); |
| 92 | 94 | $this->info(self::BACKGROUND_MOD_MEX); |
| 93 | - foreach ($companies as $company) |
|
| 94 | - $this->makeBackground($company); |
|
| 95 | + foreach ($companies as $company) { |
|
| 96 | + $this->makeBackground($company); |
|
| 97 | + } |
|
| 95 | 98 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
| 96 | 99 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
| 97 | - } else |
|
| 98 | - foreach ($companies as $company) |
|
| 100 | + } else { |
|
| 101 | + foreach ($companies as $company) |
|
| 99 | 102 | $this->makeForeground($company); |
| 103 | + } |
|
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | /** |
@@ -106,7 +110,8 @@ discard block |
||
| 106 | 110 | private function makeBackground(Company $company) |
| 107 | 111 | { |
| 108 | 112 | $event = $this->schedule->command('optimise:meetings ' . $company->id)->withoutOverlapping(); |
| 109 | - if ($event->isDue($this->laravel)) |
|
| 110 | - $event->run($this->laravel); |
|
| 113 | + if ($event->isDue($this->laravel)) { |
|
| 114 | + $event->run($this->laravel); |
|
| 115 | + } |
|
| 111 | 116 | } |
| 112 | 117 | } |