This commit is contained in:
Baris Soner Usakli
2013-10-28 00:08:44 -04:00
parent 82e14eef35
commit afc0e25b26
2 changed files with 14 additions and 7 deletions

View File

@@ -214,10 +214,12 @@ var RDB = require('./redis.js'),
var unreadTids = [],
done = false;
function continueCondition() {
return unreadTids.length < 20 && !done;
}
async.whilst(
function() {
return unreadTids.length < 20 && !done;
},
continueCondition,
function(callback) {
RDB.zrevrange('topics:recent', start, stop, function(err, tids) {
if (err)
@@ -235,12 +237,16 @@ var RDB = require('./redis.js'),
Topics.hasReadTopics(tids, uid, function(read) {
var newtids = tids.filter(function(tid, index, self) {
return read[index] === 0;
return parseInt(read[index], 10) === 0;
});
unreadTids.push.apply(unreadTids, newtids);
start = stop + 1;
stop = start + 19;
if(continueCondition()) {
start = stop + 1;
stop = start + 19;
}
callback(null);
});
}