diff --git a/db.js b/db.js index fed675d..a649aa0 100644 --- a/db.js +++ b/db.js @@ -17,13 +17,13 @@ exports.init = function(dbPath, params, callback) { descCreateDate: descCreateDate, id: 1 }}, - // note that's unordered projection (coz number is numeric) - // TODO: pick only id as value for that rare used projection + // note that's unordered projection (coz number is numeric), + // it also contains only id {key: { projectName: pickProjectName, number: 1, id: 1 - }}, + }, value: pickId}, {key: { projectName: pickProjectName, status: 1, diff --git a/lib/notifier/index.js b/lib/notifier/index.js index 208c1ba..819b4fb 100644 --- a/lib/notifier/index.js +++ b/lib/notifier/index.js @@ -33,6 +33,7 @@ exports.init = function(params, callback) { exports._getPrevBuild = function(build, callback) { Steppy( function() { + // get id of prev build db.builds.find({ start: { projectName: build.project.name, @@ -41,6 +42,10 @@ exports._getPrevBuild = function(build, callback) { limit: 1 }, this.slot()); }, + function(err, builds) { + // get prev build by id + db.builds.find({start: {id: builds[0].id}}, this.slot()); + }, function(err, builds) { this.pass(builds[0]); },