Permalink
Browse files

Merge pull request #188 from ijayasin/master

Update `updated_at` timestamp during `log`, `progress`, `attempt`, or `state` changes.
  • Loading branch information...
2 parents 6db47cd + 785e80a commit 287477f7d856a6041ab54e02e0c7529479de3304 @drudge drudge committed Mar 19, 2013
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/queue/job.js
View
@@ -288,6 +288,7 @@ Job.prototype.log = function(str){
});
this.client.rpush('q:job:' + this.id + ':log', str);
+ this.set('updated_at', Date.now());
return this;
};
@@ -334,6 +335,7 @@ Job.prototype.progress = function(complete, total){
if (0 == arguments.length) return this._progress;
var n = Math.min(100, complete / total * 100 | 0);
this.set('progress', n);
+ this.set('updated_at', Date.now());
events.emit(this.id, 'progress', n);
return this;
};
@@ -388,6 +390,7 @@ Job.prototype.attempt = function(fn){
client.hsetnx(key, 'max_attempts', 1, function(){
client.hget(key, 'max_attempts', function(err, max){
client.hincrby(key, 'attempts', 1, function(err, attempts){
+ self.set('updated_at', Date.now());
fn(err, Math.max(0, max - attempts), attempts, max);
});
});
@@ -460,6 +463,7 @@ Job.prototype.state = function(state){
client.zadd('q:jobs:' + this.type + ':' + state, this._priority, this.id);
// increase available jobs, used by Worker#getJob()
if ('inactive' == state) client.lpush('q:' + this.type + ':jobs', 1);
+ this.set('updated_at', Date.now());
return this;
};

0 comments on commit 287477f

Please sign in to comment.