Created
February 21, 2013 19:09
-
-
Save shinecita/5007228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.getUntrackedSimilar = function(user, done) { | |
var excludeIds = user.similarTracked || []; | |
excludeIds.push(user._id); | |
User | |
.find({ | |
_id: {$nin : excludeIds}, | |
tags: {$in: user.tags}, | |
name : {$exists : true, $ne : null, $ne : ""} | |
}, {limit: 5}, function(err, users) { | |
// Temporary fix for avoiding users with name :"" | |
if (users) console.log("users", users.map(function(u){ return u._id})); | |
if (users) { | |
users = users.filter(function(user) {return (user.name != "" && user.name != null) }); | |
} | |
done(err, users); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment