From e10eaf0d50ed9591c1aed5221932d58501d7d3e3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 14 Aug 2014 21:12:12 -0400 Subject: [PATCH] added tag counts to api return --- src/database/level/sorted.js | 4 ++++ src/database/mongo/sorted.js | 4 ++++ src/database/redis/sorted.js | 11 +++++++++++ src/topics/tags.js | 32 +++++++++++++++++++++++--------- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/database/level/sorted.js b/src/database/level/sorted.js index 623774aac2..46305c56d1 100644 --- a/src/database/level/sorted.js +++ b/src/database/level/sorted.js @@ -113,6 +113,10 @@ module.exports = function(db, module) { }); }; + module.sortedSetsCard = function(keys, callback) { + async.map(keys, module.sortedSetCard, callback); + }; + module.sortedSetRank = function(key, value, callback) { module.getListRange(key, 0, -1, function(err, list) { for (var i = 0, ii=list.length; i< ii; i++) { diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 267446ae7e..4ba3033932 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -101,6 +101,10 @@ module.exports = function(db, module) { }); }; + module.sortedSetsCard = function(keys, callback) { + async.map(keys, module.sortedSetCard, callback); + }; + module.sortedSetRank = function(key, value, callback) { getSortedSetRank(module.getSortedSetRange, key, value, callback); }; diff --git a/src/database/redis/sorted.js b/src/database/redis/sorted.js index 59bffa685a..9f1b124711 100644 --- a/src/database/redis/sorted.js +++ b/src/database/redis/sorted.js @@ -51,6 +51,17 @@ module.exports = function(redisClient, module) { redisClient.zcard(key, callback); }; + module.sortedSetsCard = function(keys, callback) { + if (Array.isArray(keys) && !keys.length) { + return callback(null, []); + } + var multi = redisClient.multi(); + for(var i=0; i