Add listWorkInProgressJobByUser function

This commit is contained in:
Daniel García Aubert 2016-10-27 18:43:28 +02:00
parent 8f65e6b16c
commit f65208ba0d
2 changed files with 18 additions and 3 deletions

View File

@ -180,6 +180,12 @@ JobBackend.prototype.addWorkInProgressJob = function (user, jobId, callback) {
], callback);
};
JobBackend.prototype.listWorkInProgressJobByUser = function (user, callback) {
var userWIPKey = WORK_IN_PROGRESS_JOB.PREFIX + user;
this.metadataBackend.redisCmd(WORK_IN_PROGRESS_JOB.DB, 'LRANGE', [userWIPKey, 0, -1], callback);
};
JobBackend.prototype.setTTL = function (job, callback) {
var self = this;
var redisKey = REDIS_PREFIX + job.job_id;

View File

@ -33,9 +33,9 @@ function createWadusJob() {
describe('job backend', function() {
var jobBackend = new JobBackend(metadataBackend, jobQueue);
// after(function (done) {
// redisUtils.clean('batch:*', done);
// });
after(function (done) {
redisUtils.clean('batch:*', done);
});
it('.create() should persist a job', function (done) {
var job = createWadusJob();
@ -109,4 +109,13 @@ describe('job backend', function() {
});
});
it('.listWorkInProgressJobByUser() should retrieve WIP jobs of given user', function (done) {
jobBackend.listWorkInProgressJobByUser('vizzuality', function (err, jobs) {
if (err) {
return done(err);
}
assert.ok(jobs.length);
done();
});
});
});