diff --git a/src/routes/tasks.js b/src/routes/tasks.js index 21303fe72..746bf3c16 100644 --- a/src/routes/tasks.js +++ b/src/routes/tasks.js @@ -52,7 +52,7 @@ function list(req, res, next) { if (req.query.type && typeof req.query.type !== 'string') return next(new HttpError(400, 'type must be a string')); - tasks.listPaged(req.query.type || null, page, perPage, function (error, tasks) { + tasks.listByTypePaged(req.query.type || null, page, perPage, function (error, tasks) { if (error) return next(new HttpError(500, error)); next(new HttpSuccess(200, { tasks })); diff --git a/src/taskdb.js b/src/taskdb.js index 969ac99da..f140b453c 100644 --- a/src/taskdb.js +++ b/src/taskdb.js @@ -5,7 +5,7 @@ exports = module.exports = { add: add, update: update, del: del, - listPaged: listPaged + listByTypePaged: listByTypePaged }; let assert = require('assert'), @@ -86,7 +86,7 @@ function del(id, callback) { }); } -function listPaged(type, page, perPage, callback) { +function listByTypePaged(type, page, perPage, callback) { assert(typeof type === 'string' || type === null); assert.strictEqual(typeof page, 'number'); assert.strictEqual(typeof perPage, 'number'); diff --git a/src/tasks.js b/src/tasks.js index 238965748..204bb4dda 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -3,7 +3,7 @@ exports = module.exports = { get: get, update: update, - listPaged: listPaged, + listByTypePaged: listByTypePaged, getLogs: getLogs, @@ -17,6 +17,7 @@ exports = module.exports = { TASK_UPDATE: 'update', TASK_MIGRATE: 'migrate', TASK_RENEW_CERTS: 'renewcerts', + TASK_RESTORE: 'restore', // testing _TASK_IDENTITY: '_identity', @@ -152,15 +153,17 @@ function stopTask(id, callback) { callback(null); } -function listPaged(type, page, perPage, callback) { +function listByTypePaged(type, page, perPage, callback) { assert(typeof type === 'string' || type === null); assert.strictEqual(typeof page, 'number'); assert.strictEqual(typeof perPage, 'number'); assert.strictEqual(typeof callback, 'function'); - taskdb.listPaged(type, page, perPage, function (error, tasks) { + taskdb.listByTypePaged(type, page, perPage, function (error, tasks) { if (error) return callback(new TaskError(TaskError.INTERNAL_ERROR, error)); + tasks.forEach((task) => { task.active = !!gTasks[task.id]; }); + callback(null, tasks); }); }