mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
removed most of the db.sortedSetCards
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user