lots of cleanup and refactor

This commit is contained in:
Baris Soner Usakli
2014-01-23 19:01:30 -05:00
parent f62c82c797
commit b0ef974590
3 changed files with 107 additions and 128 deletions

View File

@@ -439,26 +439,23 @@ var db = require('./database'),
Posts.reIndexPids = function(pids, callback) {
function reIndex(pid, callback) {
function reIndex(pid, next) {
Posts.getPostField(pid, 'content', function(err, content) {
db.searchRemove('post', pid, function() {
if(err) {
return next(err);
}
db.searchRemove('post', pid, function() {
if (content && content.length) {
db.searchIndex('post', content, pid);
}
callback(null);
next();
});
});
}
async.each(pids, reIndex, function(err) {
if (err) {
callback(err, null);
} else {
callback(null, 'Posts reindexed');
}
});
async.each(pids, reIndex, callback);
}
Posts.getFavourites = function(uid, callback) {