Skip to content

Commit

Permalink
Fix for refresh counts problem
Browse files Browse the repository at this point in the history
  • Loading branch information
peterholdsworth committed Aug 6, 2015
1 parent ae30644 commit 304850b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
26 changes: 25 additions & 1 deletion controllers/jobs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';


var bullModel = require('../models/bull');
var redisModel = require('../models/redis');

module.exports = function (app) {
Expand Down Expand Up @@ -41,4 +41,28 @@ module.exports = function (app) {
res.json(results);
});
});

app.post('/api/jobs/create', function(req, res){
var error;
var payloadObject;
var payload = req.body.payload;
var queue = req.body && req.body.queue;
if (!queue){
error = 'No queue specified';
}
if (!error){
try {
payloadObject = JSON.parse(req.body.payload);
} catch (e) {
error = 'Invalid JSON';
}
}
if (error) {
return res.status(400).send(error);
} else {
bullModel.createJob(req.app.locals.options.redis, queue, payloadObject)
.done(function(){return res.status(200).send('OK');});
}

});
};
33 changes: 1 addition & 32 deletions controllers/newjob.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var q = require('q')

var bullModel = require('../models/bull');

var redisModel = require('../models/redis');

module.exports = function (app) {
Expand All @@ -28,35 +28,4 @@ module.exports = function (app) {
});
});

app.post('/api/jobs/create', function(req, res){
var error;
var payloadObject;
var payload = req.body.payload;
var queue = req.body && req.body.queue;
if (!queue){
error = 'No queue specified';
}
if (!error){
try {
payloadObject = JSON.parse(req.body.payload);
} catch (e) {
error = 'Invalid JSON';
}
}
if (error) {
getNewJobModel(req, res).done(function(model){
model.error = error;
model.payload = payload;
model.queue = queue;
return res.render('newJob', model);
});
} else {
bullModel.createJob(req.app.locals.options.redis, queue, payloadObject).done(function(){
getNewJobModel(req, res).done(function(model){
return res.render('newJob', model);
});
});
}

});
};
6 changes: 6 additions & 0 deletions public/js/RedisHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ var RedisHandler = function(){
$.unblockUI();
});
});
},
createJob: function(){
var data = $("form1").serialize();
$.post(window.basepath + "/api/jobs/create", data).done(function(response){

});
}
};

Expand Down

0 comments on commit 304850b

Please sign in to comment.