Skip to content

Commit

Permalink
issue-19-patch (agenda#25)
Browse files Browse the repository at this point in the history
* Update agendash.js
  • Loading branch information
HugoCornu authored and vziukas committed Jun 30, 2016
1 parent f20127f commit f7c50ef
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions lib/agendash.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,23 @@ module.exports = function (agenda, options) {
/*
TODO: Need to validate user input.
*/
agenda.create(jobName,jobData)
.schedule(jobSchedule)
.repeatEvery(jobRepeatEvery)
.save(function (err) {
if (err) {
callback('Jobs not created')
}
callback()
});
var job = agenda.create(jobName,jobData)
if (jobSchedule && jobRepeatEvery) {
job.repeatAt(jobSchedule)
job.repeatEvery(jobRepeatEvery)
} else if (jobSchedule) {
job.schedule(jobSchedule)
} else if (jobRepeatEvery) {
job.repeatEvery(jobRepeatEvery)
} else {
return callback('Jobs not created')
}
job.save(function (err) {
if (err) {
return callback('Jobs not created')
}
callback()
});
} catch (e) {
callback(e.message)
}
Expand Down

0 comments on commit f7c50ef

Please sign in to comment.