-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathpending.js
35 lines (29 loc) · 1.02 KB
/
pending.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
var redisModel = require('../models/redis'),
q = require('q');
module.exports = function (app) {
var getPendingModel = function(req, res){
var dfd = q.defer();
redisModel.getStatus("wait").done(function(active){
redisModel.getJobsInList(active).done(function(keys){
redisModel.formatKeys(keys).done(function(keyList){
redisModel.getStatusCounts().done(function(countObject){
var model = { keys: keyList, counts: countObject, pending: true, type: "Pending" };
dfd.resolve(model);
});
});
});
});
return dfd.promise;
};
app.get('/pending', function (req, res) {
getPendingModel(req, res).done(function(model){
res.render('jobList', model);
});
});
app.get('/api/pending', function (req, res) {
getPendingModel(req, res).done(function(model){
res.json(model);
});
});
};