Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api to match new agenda version #93

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/agendash.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ module.exports = function(agenda, options) {
return callback('Jobs not found');
}
async.series(jobs.map(job => done => {
const newJob = agenda.create(job.name, job.data).save(() => {
agenda.create(job.name, job.data).save().then(newJob => {
done(null, newJob);
}, err => {
done(err);
});
}), (err, results) => {
callback(err, results);
Expand All @@ -236,11 +238,13 @@ module.exports = function(agenda, options) {
}
try {
const collection = agenda._collection.collection || agenda._collection;
agenda.cancel({_id: {$in: jobIds.map(jobId => collection.s.pkFactory(jobId))}}, (err, deleted) => {
if (err || !deleted) {
callback('Jobs not deleted');
agenda.cancel({_id: {$in: jobIds.map(jobId => collection.s.pkFactory(jobId))}}).then(deleted => {
if (!deleted) {
return callback('Jobs not deleted');
}
callback();
}, err => {
callback(err.message);
});
} catch (err) {
callback(err.message);
Expand All @@ -264,11 +268,10 @@ module.exports = function(agenda, options) {
} else {
return callback('Jobs not created');
}
job.save(err => {
if (err) {
return callback('Jobs not created');
}
job.save().then(() => {
callback();
}, err => {
callback(err.message);
});
} catch (err) {
callback(err.message);
Expand Down
4 changes: 3 additions & 1 deletion public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ $(function () {
this._fetchRequest = $.get('api', {
job: this.currentRequest.get('job'),
state: this.currentRequest.get('state')
}).success(this.resultsFetched)
}).success(this.resultsFetched).complete(this.fetchDataRequeue.bind(this))
},
resultsFetched: function (results) {
this.overviewItems.set(results.overview)
Expand All @@ -392,6 +392,8 @@ $(function () {
})
this.render(results)
this.jobItems.set(results.jobs)
},
fetchDataRequeue: function () {
this._fetchTimeout = setTimeout(this.fetchData, this.currentRequest.get('refreshInterval'))
},
render: function (results) {
Expand Down