@@ -340,12 +340,19 @@ Job.prototype.toJSON = function() {
340
340
} ;
341
341
342
342
343
- Job . prototype . refreshTtl = function ( ) {
344
- ( 'active' === this . state ( ) && this . _ttl > 0 )
343
+ /**
344
+ * Refreshes Time to live of the job in jobs:`state` zset
345
+ *
346
+ * @param {Function } [clbk]
347
+ */
348
+
349
+ Job . prototype . refreshTtl = function ( clbk ) {
350
+ clbk = clbk || noop ;
351
+ return ( 'active' === this . state ( ) && this . _ttl > 0 )
345
352
?
346
- this . client . zadd ( this . client . getKey ( 'jobs:' + this . state ( ) ) , Date . now ( ) + parseInt ( this . _ttl ) , this . zid , noop )
353
+ this . client . zadd ( this . client . getKey ( 'jobs:' + this . state ( ) ) , Date . now ( ) + parseInt ( this . _ttl ) , this . zid , clbk )
347
354
:
348
- noop ( ) ;
355
+ clbk ( ) ;
349
356
} ;
350
357
351
358
@@ -417,13 +424,15 @@ Job.prototype.get = function( key, fn ) {
417
424
*
418
425
* @param {Number } complete
419
426
* @param {Number } total
420
- * @param {Object } data
427
+ * @param {Object } [data]
428
+ * @param {Function } [clbk]
421
429
* @return {Job } for chaining
422
430
* @api public
423
431
*/
424
432
425
- Job . prototype . progress = function ( complete , total , data ) {
433
+ Job . prototype . progress = function ( complete , total , data , clbk ) {
426
434
if ( 0 == arguments . length ) return this . _progress ;
435
+ if ( undefined === clbk && 'function' === typeof data ) clbk = data ;
427
436
var n = Math . min ( 100 , complete * 100 / total | 0 ) ;
428
437
this . set ( 'progress' , n ) ;
429
438
@@ -432,7 +441,7 @@ Job.prototype.progress = function( complete, total, data ) {
432
441
if ( data ) this . set ( 'progress_data' , JSON . stringify ( data ) ) ;
433
442
434
443
this . set ( 'updated_at' , Date . now ( ) ) ;
435
- this . refreshTtl ( ) ;
444
+ this . refreshTtl ( clbk ) ;
436
445
events . emit ( this . id , 'progress' , n , data ) ;
437
446
return this ;
438
447
} ;
0 commit comments