This commit is contained in:
Baris Usakli
2017-10-19 13:53:05 -04:00
parent 8733f51f86
commit 19dc7da42f
7 changed files with 80 additions and 68 deletions

View File

@@ -125,6 +125,8 @@ module.exports = function (Topics) {
if (params.filter === 'watched') {
Topics.filterWatchedTids(tids, uid, next);
} else if (params.filter === 'unreplied') {
Topics.filterUnrepliedTids(tids, next);
} else {
next(null, tids);
}
@@ -390,4 +392,18 @@ module.exports = function (Topics) {
},
], callback);
};
Topics.filterUnrepliedTids = function (tids, callback) {
async.waterfall([
function (next) {
db.sortedSetScores('topics:posts', tids, next);
},
function (scores, next) {
tids = tids.filter(function (tid, index) {
return tid && scores[index] <= 1;
});
next(null, tids);
},
], callback);
};
};