Comparing version 0.4.1 to 0.4.2
0.4.2 / 2013-12-11 | ||
================== | ||
* Refactored Job to ensure that everything is stored as an ISODate in the Database. [Closes #14] [@raisch] | ||
0.4.1 / 2013-12-10 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -104,3 +104,7 @@ var Job = require('./job.js'), | ||
var fn = cb; | ||
var props = getJobProperties(job); | ||
var props = job.toJSON(); | ||
delete props._id; | ||
if(props.type == 'single') | ||
@@ -151,3 +155,5 @@ this._db.findAndModify({name: props.name, type: 'single'}, {}, {$set: props}, {upsert: true, new: true}, processDbResult); | ||
self = this; | ||
var now = new Date(); | ||
this.jobs({nextRunAt: {$lte: now}}, {sort: {'priority': -1}}, function(err, jobs) { | ||
@@ -183,10 +189,1 @@ if(err) throw(err); | ||
} | ||
function getJobProperties(job) { | ||
var props = {}; | ||
for(var key in job.attrs) { | ||
props[key] = job.attrs[key]; | ||
} | ||
delete props._id; | ||
return props; | ||
} |
@@ -26,2 +26,17 @@ var humanInterval = require('human-interval'), | ||
Job.prototype.toJSON=function(){ // create a persistable Mongo object -RR | ||
var self=this, | ||
attrs=self.attrs||{}; | ||
return { | ||
_id: attrs._id, | ||
name: attrs.name, | ||
data: attrs.data, | ||
priority: attrs.priority, | ||
lastRunAt: attrs.lastRunAt ? new Date(attrs.lastRunAt) : null, | ||
lastFinishedAt:attrs.lastFinishedAt ? new Date(attrs.lastFinishedAt) : null, | ||
nextRunAt: attrs.nextRunAt ? new Date(attrs.nextRunAt) : null, | ||
repeatInterval:attrs.repeatInterval, | ||
type: attrs.type | ||
}; | ||
}; | ||
@@ -28,0 +43,0 @@ Job.prototype.computeNextRunAt = function() { |
{ | ||
"name": "agenda", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Light weight job scheduler for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33790
650