@@ -3,8 +3,6 @@ |
||
3 | 3 | namespace plunner\Listeners; |
4 | 4 | |
5 | 5 | use plunner\Events\CaldavErrorEvent; |
6 | -use Illuminate\Queue\InteractsWithQueue; |
|
7 | -use Illuminate\Contracts\Queue\ShouldQueue; |
|
8 | 6 | |
9 | 7 | class CaldavErrorListener |
10 | 8 | { |
@@ -32,8 +32,8 @@ |
||
32 | 32 | protected $description = 'Optimise meetings'; |
33 | 33 | |
34 | 34 | /** |
35 | - * @var Schedule laravel schedule object needed to perform command in background |
|
36 | - */ |
|
35 | + * @var Schedule laravel schedule object needed to perform command in background |
|
36 | + */ |
|
37 | 37 | private $schedule; |
38 | 38 | |
39 | 39 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | //TODO try...catch with destruct |
64 | 64 | $companyId = $this->argument('companyId'); |
65 | - if(is_numeric($companyId)) |
|
65 | + if (is_numeric($companyId)) |
|
66 | 66 | $this->makeForeground(Company::findOrFail($companyId)); |
67 | 67 | else |
68 | 68 | $this->syncAll(); |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | private function syncAll() |
72 | 72 | { |
73 | 73 | $calendars = Caldav::all(); |
74 | - if($this->option('background')) { |
|
74 | + if ($this->option('background')) { |
|
75 | 75 | \Log::debug(self::BACKGROUND_MOD_MEX); |
76 | 76 | $this->info(self::BACKGROUND_MOD_MEX); |
77 | 77 | foreach ($calendars as $calendar) |
78 | 78 | $this->makeBackground($calendar); |
79 | 79 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
80 | 80 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
81 | - }else |
|
82 | - foreach($calendars as $calendar) |
|
81 | + } else |
|
82 | + foreach ($calendars as $calendar) |
|
83 | 83 | $this->makeForeground($calendar); |
84 | 84 | } |
85 | 85 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | private function makeBackground(Company $company) |
91 | 91 | { |
92 | 92 | $event = $this->schedule->command('optimise:meetings '.$company->id)->withoutOverlapping(); |
93 | - if($event->isDue($this->laravel)) |
|
93 | + if ($event->isDue($this->laravel)) |
|
94 | 94 | $event->run($this->laravel); |
95 | 95 | } |
96 | 96 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | */ |
101 | 101 | private function makeForeground(Company $company) |
102 | 102 | { |
103 | - $this->info('Optimisation company '. $company->id.' started'); |
|
103 | + $this->info('Optimisation company '.$company->id.' started'); |
|
104 | 104 | (new Optimise($company))->optimise()->save(); |
105 | - $this->info('Optimisation '. $company->id.' completed'); |
|
105 | + $this->info('Optimisation '.$company->id.' completed'); |
|
106 | 106 | } |
107 | 107 | } |
@@ -62,10 +62,11 @@ discard block |
||
62 | 62 | |
63 | 63 | //TODO try...catch with destruct |
64 | 64 | $companyId = $this->argument('companyId'); |
65 | - if(is_numeric($companyId)) |
|
66 | - $this->makeForeground(Company::findOrFail($companyId)); |
|
67 | - else |
|
68 | - $this->syncAll(); |
|
65 | + if(is_numeric($companyId)) { |
|
66 | + $this->makeForeground(Company::findOrFail($companyId)); |
|
67 | + } else { |
|
68 | + $this->syncAll(); |
|
69 | + } |
|
69 | 70 | } |
70 | 71 | |
71 | 72 | private function syncAll() |
@@ -74,13 +75,15 @@ discard block |
||
74 | 75 | if($this->option('background')) { |
75 | 76 | \Log::debug(self::BACKGROUND_MOD_MEX); |
76 | 77 | $this->info(self::BACKGROUND_MOD_MEX); |
77 | - foreach ($calendars as $calendar) |
|
78 | - $this->makeBackground($calendar); |
|
78 | + foreach ($calendars as $calendar) { |
|
79 | + $this->makeBackground($calendar); |
|
80 | + } |
|
79 | 81 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
80 | 82 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
81 | - }else |
|
82 | - foreach($calendars as $calendar) |
|
83 | + } else { |
|
84 | + foreach($calendars as $calendar) |
|
83 | 85 | $this->makeForeground($calendar); |
86 | + } |
|
84 | 87 | } |
85 | 88 | |
86 | 89 | /** |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | private function makeBackground(Company $company) |
91 | 94 | { |
92 | 95 | $event = $this->schedule->command('optimise:meetings '.$company->id)->withoutOverlapping(); |
93 | - if($event->isDue($this->laravel)) |
|
94 | - $event->run($this->laravel); |
|
96 | + if($event->isDue($this->laravel)) { |
|
97 | + $event->run($this->laravel); |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | /** |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: Claudio Cardinale <[email protected]> |
|
5 | - * Date: 07/12/15 |
|
6 | - * Time: 21.24 |
|
7 | - * This program is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU General Public License |
|
9 | - * as published by the Free Software Foundation; either version 2 |
|
10 | - * of the License, or (at your option) any later version. |
|
11 | - * This program is distributed in the hope that it will be useful, |
|
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | - * GNU General Public License for more details. |
|
15 | - * You should have received a copy of the GNU General Public License |
|
16 | - * along with this program; if not, write to the Free Software |
|
17 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: Claudio Cardinale <[email protected]> |
|
5 | + * Date: 07/12/15 |
|
6 | + * Time: 21.24 |
|
7 | + * This program is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU General Public License |
|
9 | + * as published by the Free Software Foundation; either version 2 |
|
10 | + * of the License, or (at your option) any later version. |
|
11 | + * This program is distributed in the hope that it will be useful, |
|
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | + * GNU General Public License for more details. |
|
15 | + * You should have received a copy of the GNU General Public License |
|
16 | + * along with this program; if not, write to the Free Software |
|
17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | namespace plunner\Console\Commands\Optimise; |
21 | 21 |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @var array |
50 | 50 | */ |
51 | - protected $fillable = ['name', 'email', 'password']; |
|
51 | + protected $fillable = [ 'name', 'email', 'password' ]; |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * The attributes excluded from the model's JSON form. |
55 | 55 | * |
56 | 56 | * @var array |
57 | 57 | */ |
58 | - protected $hidden = ['password', 'remember_token']; |
|
58 | + protected $hidden = [ 'password', 'remember_token' ]; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | ->where('calendars.enabled', '=', '1') |
121 | 121 | ->where('timeslots.time_start', '>=', $from) |
122 | 122 | ->where('timeslots.time_end', '<=', $to) |
123 | - ->where('employees.company_id','=', $this->id) |
|
124 | - ->select('employees.id','timeslots.time_start','timeslots.time_end') |
|
123 | + ->where('employees.company_id', '=', $this->id) |
|
124 | + ->select('employees.id', 'timeslots.time_start', 'timeslots.time_end') |
|
125 | 125 | ->get(); |
126 | 126 | } |
127 | 127 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | ->join('meeting_timeslots', 'meetings.id', '=', 'meeting_timeslots.meeting_id') |
138 | 138 | ->where('meeting_timeslots.time_start', '>=', $from) |
139 | 139 | ->where('meeting_timeslots.time_end', '<=', $to) |
140 | - ->where('groups.company_id','=', $this->id) |
|
140 | + ->where('groups.company_id', '=', $this->id) |
|
141 | 141 | //->where('meetings.start_time','=', 'NULL') |
142 | - ->select('meetings.id', 'meetings.duration','meeting_timeslots.time_start','meeting_timeslots.time_end') |
|
142 | + ->select('meetings.id', 'meetings.duration', 'meeting_timeslots.time_start', 'meeting_timeslots.time_end') |
|
143 | 143 | ->get(); |
144 | 144 | } |
145 | 145 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | ->join('employees', 'employee_group.employee_id', '=', 'employees.id') |
152 | 152 | ->whereIn('employees.id', $users) |
153 | 153 | ->whereIn('meetings.id', $meetings) |
154 | - ->where('groups.company_id','=', $this->id) //this is not needed |
|
155 | - ->where('employees.company_id','=', $this->id) //this is not needed |
|
154 | + ->where('groups.company_id', '=', $this->id) //this is not needed |
|
155 | + ->where('employees.company_id', '=', $this->id) //this is not needed |
|
156 | 156 | ->select('employees.id as employee_id', 'meetings.id as meeting_id') |
157 | 157 | ->get(); |
158 | 158 | } |
@@ -39,6 +39,6 @@ |
||
39 | 39 | */ |
40 | 40 | public function broadcastOn() |
41 | 41 | { |
42 | - return []; |
|
42 | + return [ ]; |
|
43 | 43 | } |
44 | 44 | } |
@@ -39,6 +39,6 @@ |
||
39 | 39 | */ |
40 | 40 | public function broadcastOn() |
41 | 41 | { |
42 | - return []; |
|
42 | + return [ ]; |
|
43 | 43 | } |
44 | 44 | } |