@@ -19,7 +19,7 @@ class QueuedTasksTable extends Table {
1919 public $ exit = false ;
2020
2121 public $ findMethods = [
22- 'progress ' => true
22+ 'progress ' => true ,
2323 ];
2424
2525 protected $ _key = null ;
@@ -70,7 +70,7 @@ public function createJob($jobName, $data = null, $notBefore = null, $group = nu
7070 'jobtype ' => $ jobName ,
7171 'data ' => serialize ($ data ),
7272 'task_group ' => $ group ,
73- 'reference ' => $ reference
73+ 'reference ' => $ reference,
7474 ];
7575 if ($ notBefore !== null ) {
7676 $ data ['notbefore ' ] = strtotime ($ notBefore );
@@ -101,8 +101,8 @@ public function onError() {
101101 public function getLength ($ type = null ) {
102102 $ findConf = [
103103 'conditions ' => [
104- 'completed IS ' => null
105- ]
104+ 'completed IS ' => null ,
105+ ],
106106 ];
107107 if ($ type !== null ) {
108108 $ findConf ['conditions ' ]['jobtype ' ] = $ type ;
@@ -119,10 +119,10 @@ public function getLength($type = null) {
119119 public function getTypes () {
120120 $ findCond = [
121121 'fields ' => [
122- 'jobtype '
122+ 'jobtype ' ,
123123 ],
124124 'group ' => [
125- 'jobtype '
125+ 'jobtype ' ,
126126 ],
127127 'keyField ' => 'jobtype ' ,
128128 'valueField ' => 'jobtype ' ,
@@ -148,11 +148,11 @@ public function getStats() {
148148 ];
149149 },
150150 'conditions ' => [
151- 'completed IS NOT ' => null
151+ 'completed IS NOT ' => null ,
152152 ],
153153 'group ' => [
154- 'jobtype '
155- ]
154+ 'jobtype ' ,
155+ ],
156156 ];
157157 return $ this ->find ('all ' , $ options );
158158 }
@@ -173,7 +173,7 @@ public function requestJob(array $capabilities, $group = null) {
173173 $ findCond = [
174174 'conditions ' => [
175175 'completed IS ' => null ,
176- 'OR ' => []
176+ 'OR ' => [],
177177 ],
178178 'fields ' => function ($ query ) {
179179 return [
@@ -186,9 +186,9 @@ public function requestJob(array $capabilities, $group = null) {
186186 },
187187 'order ' => [
188188 'age ASC ' ,
189- 'id ASC '
189+ 'id ASC ' ,
190190 ],
191- 'limit ' => 3
191+ 'limit ' => 3 ,
192192 ];
193193
194194 if ($ group !== null ) {
@@ -204,17 +204,17 @@ public function requestJob(array $capabilities, $group = null) {
204204 [
205205 'OR ' => [
206206 'notbefore < ' => time (),
207- 'notbefore IS ' => null
208- ]
207+ 'notbefore IS ' => null ,
208+ ],
209209 ],
210210 [
211211 'OR ' => [
212212 'fetched < ' => time () - $ task ['timeout ' ],
213- 'fetched IS ' => null
214- ]
215- ]
213+ 'fetched IS ' => null ,
214+ ],
215+ ],
216216 ],
217- 'failed < ' => ($ task ['retries ' ] + 1 )
217+ 'failed < ' => ($ task ['retries ' ] + 1 ),
218218 ];
219219 if (array_key_exists ('rate ' , $ task ) && $ tmp ['jobtype ' ] && array_key_exists ($ tmp ['jobtype ' ], $ this ->rateHistory )) {
220220 $ tmp ['UNIX_TIMESTAMP() >= ' ] = $ this ->rateHistory [$ tmp ['jobtype ' ]] + $ task ['rate ' ];
@@ -250,7 +250,7 @@ public function requestJob(array $capabilities, $group = null) {
250250 'workerkey ' => $ key ,
251251 'completed IS ' => null ,
252252 ],
253- 'order ' => ['fetched ' => 'DESC ' ]
253+ 'order ' => ['fetched ' => 'DESC ' ],
254254 ])->first ();
255255
256256 if (!$ data ) {
@@ -291,10 +291,10 @@ public function updateProgress($id, $progress) {
291291 */
292292 public function markJobDone ($ id ) {
293293 $ fields = [
294- 'completed ' => time ()
294+ 'completed ' => time (),
295295 ];
296296 $ conditions = [
297- 'id ' => $ id
297+ 'id ' => $ id,
298298 ];
299299 return $ this ->updateAll ($ fields , $ conditions );
300300 }
@@ -314,7 +314,7 @@ public function reset() {
314314 'failure_message ' => null ,
315315 ];
316316 $ conditions = [
317- 'completed IS ' => null
317+ 'completed IS ' => null ,
318318 ];
319319 return $ this ->updateAll ($ fields , $ conditions );
320320 }
@@ -336,7 +336,7 @@ public function markJobFailed($id, $failureMessage = null) {
336336 'failure_message ' => $ failureMessage ,
337337 ];
338338 $ conditions = [
339- 'id ' => $ id
339+ 'id ' => $ id,
340340 ];
341341 return $ this ->updateAll ($ fields , $ conditions );
342342 }
@@ -356,11 +356,11 @@ public function getPendingStats() {
356356 'progress ' ,
357357 'reference ' ,
358358 'failed ' ,
359- 'failure_message '
359+ 'failure_message ' ,
360360 ],
361361 'conditions ' => [
362- 'completed IS ' => null
363- ]
362+ 'completed IS ' => null ,
363+ ],
364364 ];
365365 return $ this ->find ('all ' , $ findCond );
366366 }
@@ -372,7 +372,7 @@ public function getPendingStats() {
372372 */
373373 public function cleanOldJobs () {
374374 $ this ->deleteAll ([
375- 'completed < ' => time () - Configure::read ('Queue.cleanuptimeout ' )
375+ 'completed < ' => time () - Configure::read ('Queue.cleanuptimeout ' ),
376376 ]);
377377 if (!($ pidFilePath = Configure::read ('Queue.pidfilepath ' ))) {
378378 return ;
@@ -428,7 +428,7 @@ protected function _findProgress($state, $query = [], $results = []) {
428428 'reference ' ,
429429 'status ' ,
430430 'progress ' ,
431- 'failure_message '
431+ 'failure_message ' ,
432432 ];
433433 if (isset ($ query ['conditions ' ]['exclude ' ])) {
434434 $ exclude = $ query ['conditions ' ]['exclude ' ];
@@ -437,8 +437,8 @@ protected function _findProgress($state, $query = [], $results = []) {
437437 $ exclude = explode (', ' , $ exclude );
438438 $ query ['conditions ' ][] = [
439439 'NOT ' => [
440- 'reference ' => $ exclude
441- ]
440+ 'reference ' => $ exclude,
441+ ],
442442 ];
443443 }
444444 if (isset ($ query ['conditions ' ]['task_group ' ])) {
@@ -451,7 +451,7 @@ protected function _findProgress($state, $query = [], $results = []) {
451451 foreach ($ results as $ k => $ result ) {
452452 $ results [$ k ] = [
453453 'reference ' => $ result ['reference ' ],
454- 'status ' => $ result ['status ' ]
454+ 'status ' => $ result ['status ' ],
455455 ];
456456 if (!empty ($ result ['progress ' ])) {
457457 $ results [$ k ]['progress ' ] = $ result ['progress ' ];
@@ -480,9 +480,9 @@ public function clearDoublettes() {
480480 $ numX = count ($ x );
481481 while ($ start <= $ numX ) {
482482 $ this ->deleteAll ([
483- 'id ' => array_slice ($ x , $ start , 10 )
483+ 'id ' => array_slice ($ x , $ start , 10 ),
484484 ]);
485- debug (array_slice ($ x , $ start , 10 ));
485+ // debug(array_slice($x, $start, 10));
486486 $ start = $ start + 100 ;
487487 }
488488 }
0 commit comments