Skip to content

Commit

Permalink
Fixes #12 - incorrect sort order during a build.
Browse files Browse the repository at this point in the history
- Spotting that MongoHub was also listing the 
  current build in a random order, I fixed this 
  issue by just forcing a sort order. Performance
  doesn't seem like it's the most important thing
  for an app like this.
- I wonder if the issue is related to natural vs
  insertion sort order, see:
  http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order
  • Loading branch information
Philip Roberts committed Apr 10, 2012
1 parent f902a5a commit efd58a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/jobs.js
Expand Up @@ -131,11 +131,15 @@
getJobs = function(filter, next) {
return db.collection('jobs', function(error, collection) {
if (filter != null) {
return collection.find(filter).toArray(function(error, results) {
return collection.find(filter).sort({
addedTime: 1
}).toArray(function(error, results) {
return next(results);
});
} else {
return collection.find().toArray(function(error, results) {
return collection.find().sort({
addedTime: 1
}).toArray(function(error, results) {
return next(results);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/jobs.coffee
Expand Up @@ -91,8 +91,8 @@ jobs = module.exports =
getJobs = (filter, next)->
db.collection 'jobs', (error, collection) ->
if filter?
collection.find(filter).toArray (error, results) ->
collection.find(filter).sort({addedTime: 1}).toArray (error, results) ->
next results
else
collection.find().toArray (error, results) ->
collection.find().sort({addedTime: 1}).toArray (error, results) ->
next results

0 comments on commit efd58a5

Please sign in to comment.