node-resque
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -166,10 +166,14 @@ var util = require('util'); | ||
started++; | ||
self.connection.redis.lrem(key, 0, search, function(){ | ||
self.connection.redis.srem(self.connection.key("timestamps:" + search), key, function(){ | ||
timestamps.push(key.split(":")[key.split(":").length - 1]); | ||
started--; | ||
if(started === 0){ | ||
if(typeof callback === 'function'){ callback(err, timestamps); } | ||
} | ||
}); | ||
self.connection.redis.lrem(self.connection.key(key), 0, search, function(err, count){ | ||
if(count > 0) { | ||
self.connection.redis.srem(self.connection.key("timestamps:" + search), key, function(){ | ||
timestamps.push(key.split(":")[key.split(":").length - 1]); | ||
started--; | ||
if(started === 0){ | ||
if(typeof callback === 'function'){ callback(err, timestamps); } | ||
} | ||
}); | ||
} else { | ||
if(typeof callback === 'function'){ callback(err, []); } | ||
} | ||
}); | ||
@@ -176,0 +180,0 @@ }); |
@@ -6,3 +6,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"homepage": "http://github.com/taskrabbit/node-resque", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -175,2 +175,15 @@ var specHelper = require(__dirname + "/../_specHelper.js").specHelper; | ||
it('can delete a delayed job, and delayed queue should be empty', function(done){ | ||
queue.enqueueAt(10000, specHelper.queue, 'someJob', [1,2,3], function(){ | ||
queue.delDelayed(specHelper.queue, 'someJob', [1,2,3], function(err, timestamps){ | ||
queue.allDelayed(function(err, hash){ | ||
hash.should.be.empty(); | ||
timestamps.length.should.equal(1); | ||
timestamps[0].should.equal('10'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('can handle single arguments without explicit array', function(done){ | ||
@@ -251,7 +264,8 @@ queue.enqueue(specHelper.queue, 'someJob', 1, function(){ | ||
Object.keys(hash).length.should.equal(2); | ||
queue.delDelayed(specHelper.queue, 'noParams'); | ||
queue.delDelayed(specHelper.queue, 'noParams', function(){ | ||
queue.allDelayed(function(err, hash){ | ||
hash.should.be.empty; | ||
done(); | ||
queue.delDelayed(specHelper.queue, 'noParams', function(){ | ||
queue.allDelayed(function(err, hash){ | ||
hash.should.be.empty; | ||
done(); | ||
}); | ||
}); | ||
@@ -258,0 +272,0 @@ }); |
528015
3986