Node.js based forum software built for the modern web
removed most of the db.sortedSetCards
barisusakli761f56aeb17a
diff --git a/public/src/client/category.js b/public/src/client/category.jsindex 1cc0a9fa02..a40781e642 100644--- a/public/src/client/category.js+++ b/public/src/client/category.js@@ -73,7 +73,7 @@ define('forum/category', ['composer', 'forum/pagination', 'forum/infinitescroll'};Category.toBottom = function() {- socket.emit('categories.lastTopicIndex', ajaxify.variables.get('category_id'), function(err, index) {+ socket.emit('categories.getTopicCount', ajaxify.variables.get('category_id'), function(err, index) {navigator.scrollBottom(index);});};@@ -180,7 +180,7 @@ define('forum/category', ['composer', 'forum/pagination', 'forum/infinitescroll'Category.onNewTopic = function(topic) {$(window).trigger('filter:categories.new_topic', topic);-+templates.parse('category', 'topics', {privileges: {editable: !!$('.thread-tools').length},topics: [topic]diff --git a/src/categories.js b/src/categories.jsindex 7be6d0a6ef..9f7c877bd7 100644--- a/src/categories.js+++ b/src/categories.js@@ -167,8 +167,8 @@ var db = require('./database'),};Categories.getPageCount = function(cid, uid, callback) {- db.sortedSetCard('categories:' + cid + ':tid', function(err, topicCount) {- if(err) {+ Catgories.getCategoryField(cid, 'topic_count', function(err, topicCount) {+ if (err) {return callback(err);}@@ -177,7 +177,7 @@ var db = require('./database'),}user.getSettings(uid, function(err, settings) {- if(err) {+ if (err) {return callback(err);}diff --git a/src/controllers/users.js b/src/controllers/users.jsindex bdc3fceb70..84fde728fd 100644--- a/src/controllers/users.js+++ b/src/controllers/users.js@@ -63,7 +63,7 @@ function getUsers(set, res, next) {user.getUsersFromSet(set, 0, 49, next);},count: function(next) {- db.sortedSetCard(set, next);+ db.getObjectField('global', 'userCount', next);}}, function(err, results) {if (err) {diff --git a/src/middleware/middleware.js b/src/middleware/middleware.jsindex 599689e647..fb0ad3937e 100644--- a/src/middleware/middleware.js+++ b/src/middleware/middleware.js@@ -128,7 +128,7 @@ middleware.addSlug = function(req, res, next) {};middleware.checkTopicIndex = function(req, res, next) {- db.sortedSetCard('categories:' + req.params.category_id + ':tid', function(err, topicCount) {+ categories.getCategoryField(req.params.category_id, 'topic_count', function(err, topicCount) {if (err) {return next(err);}diff --git a/src/socket.io/categories.js b/src/socket.io/categories.jsindex d92f18ca19..e1bb838dd7 100644--- a/src/socket.io/categories.js+++ b/src/socket.io/categories.js@@ -71,10 +71,6 @@ SocketCategories.getTopicCount = function(socket, cid, callback) {categories.getCategoryField(cid, 'topic_count', callback);};-SocketCategories.lastTopicIndex = function(socket, cid, callback) {- db.sortedSetCard('categories:' + cid + ':tid', callback);-};-SocketCategories.getUsersInCategory = function(socket, cid, callback) {var uids = websockets.getUidsInRoom('category_' + cid);user.getMultipleUserFields(uids, ['uid', 'userslug', 'username', 'picture'], callback);diff --git a/src/topics.js b/src/topics.jsindex a8aeba052d..4f011c937c 100644--- a/src/topics.js+++ b/src/topics.js@@ -77,11 +77,11 @@ var async = require('async'),};Topics.getPageCount = function(tid, uid, callback) {- db.sortedSetCard('tid:' + tid + ':posts', function(err, postCount) {- if(err) {+ Topics.getTopicField(tid, 'postcount', function(err, postCount) {+ if (err) {return callback(err);}- if(!parseInt(postCount, 10)) {+ if (!parseInt(postCount, 10)) {return callback(null, 1);}user.getSettings(uid, function(err, settings) {@@ -346,15 +346,22 @@ var async = require('async'),};Topics.getTeasers = function(tids, uid, callback) {- if(!Array.isArray(tids) || !tids.length) {+ if (!Array.isArray(tids) || !tids.length) {return callback(null, []);}async.parallel({counts: function(next) {- async.map(tids, function(tid, next) {- db.sortedSetCard('tid:' + tid + ':posts', next);- }, next);+ Topics.getTopicsFields(tids, ['postcount'], function(err, topics) {+ if (err) {+ return next(err);+ }+ topics = topics.map(function(topic) {+ return topic && topic.postcount;+ });++ next(null, topics);+ });},pids: function(next) {async.map(tids, function(tid, next) {diff --git a/src/topics/posts.js b/src/topics/posts.jsindex ee769add0e..67ceefe4c2 100644--- a/src/topics/posts.js+++ b/src/topics/posts.js@@ -263,7 +263,7 @@ module.exports = function(Topics) {};Topics.getPostCount = function(tid, callback) {- db.sortedSetCard('tid:' + tid + ':posts', callback);+ db.getObjectField('topic:' + tid, 'postcount', callback);};};diff --git a/src/user/notifications.js b/src/user/notifications.jsindex 731ff99da8..0981c65f1f 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -214,7 +214,9 @@ var async = require('async'),if (!parseInt(uid, 10)) {return callback(null, 0);}- db.sortedSetCard('uid:' + uid + ':notifications:unread', callback);+ db.getSortedSetRange('uid:' + uid + ':notifications:unread', 0, 20, function(err, nids) {+ callback(err, Array.isArray(nids) ? nids.length : 0);+ });};UserNotifications.getUnreadByField = function(uid, field, value, callback) {