removed most of the db.sortedSetCards

v1.18.x
barisusakli 11 years ago
parent 09bd42b9f6
commit 761f56aeb1

@ -73,7 +73,7 @@ define('forum/category', ['composer', 'forum/pagination', 'forum/infinitescroll'
}; };
Category.toBottom = function() { 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); navigator.scrollBottom(index);
}); });
}; };

@ -167,8 +167,8 @@ var db = require('./database'),
}; };
Categories.getPageCount = function(cid, uid, callback) { Categories.getPageCount = function(cid, uid, callback) {
db.sortedSetCard('categories:' + cid + ':tid', function(err, topicCount) { Catgories.getCategoryField(cid, 'topic_count', function(err, topicCount) {
if(err) { if (err) {
return callback(err); return callback(err);
} }
@ -177,7 +177,7 @@ var db = require('./database'),
} }
user.getSettings(uid, function(err, settings) { user.getSettings(uid, function(err, settings) {
if(err) { if (err) {
return callback(err); return callback(err);
} }

@ -63,7 +63,7 @@ function getUsers(set, res, next) {
user.getUsersFromSet(set, 0, 49, next); user.getUsersFromSet(set, 0, 49, next);
}, },
count: function(next) { count: function(next) {
db.sortedSetCard(set, next); db.getObjectField('global', 'userCount', next);
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {

@ -128,7 +128,7 @@ middleware.addSlug = function(req, res, next) {
}; };
middleware.checkTopicIndex = 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) { if (err) {
return next(err); return next(err);
} }

@ -71,10 +71,6 @@ SocketCategories.getTopicCount = function(socket, cid, callback) {
categories.getCategoryField(cid, 'topic_count', 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) { SocketCategories.getUsersInCategory = function(socket, cid, callback) {
var uids = websockets.getUidsInRoom('category_' + cid); var uids = websockets.getUidsInRoom('category_' + cid);
user.getMultipleUserFields(uids, ['uid', 'userslug', 'username', 'picture'], callback); user.getMultipleUserFields(uids, ['uid', 'userslug', 'username', 'picture'], callback);

@ -77,11 +77,11 @@ var async = require('async'),
}; };
Topics.getPageCount = function(tid, uid, callback) { Topics.getPageCount = function(tid, uid, callback) {
db.sortedSetCard('tid:' + tid + ':posts', function(err, postCount) { Topics.getTopicField(tid, 'postcount', function(err, postCount) {
if(err) { if (err) {
return callback(err); return callback(err);
} }
if(!parseInt(postCount, 10)) { if (!parseInt(postCount, 10)) {
return callback(null, 1); return callback(null, 1);
} }
user.getSettings(uid, function(err, settings) { user.getSettings(uid, function(err, settings) {
@ -346,15 +346,22 @@ var async = require('async'),
}; };
Topics.getTeasers = function(tids, uid, callback) { Topics.getTeasers = function(tids, uid, callback) {
if(!Array.isArray(tids) || !tids.length) { if (!Array.isArray(tids) || !tids.length) {
return callback(null, []); return callback(null, []);
} }
async.parallel({ async.parallel({
counts: function(next) { counts: function(next) {
async.map(tids, function(tid, next) { Topics.getTopicsFields(tids, ['postcount'], function(err, topics) {
db.sortedSetCard('tid:' + tid + ':posts', next); if (err) {
}, next); return next(err);
}
topics = topics.map(function(topic) {
return topic && topic.postcount;
});
next(null, topics);
});
}, },
pids: function(next) { pids: function(next) {
async.map(tids, function(tid, next) { async.map(tids, function(tid, next) {

@ -263,7 +263,7 @@ module.exports = function(Topics) {
}; };
Topics.getPostCount = function(tid, callback) { Topics.getPostCount = function(tid, callback) {
db.sortedSetCard('tid:' + tid + ':posts', callback); db.getObjectField('topic:' + tid, 'postcount', callback);
}; };
}; };

@ -214,7 +214,9 @@ var async = require('async'),
if (!parseInt(uid, 10)) { if (!parseInt(uid, 10)) {
return callback(null, 0); 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) { UserNotifications.getUnreadByField = function(uid, field, value, callback) {

Loading…
Cancel
Save