mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: use db.sortedSetsAdd
This commit is contained in:
@@ -68,10 +68,10 @@ events.log = function (data, callback) {
|
|||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetAdd('events:time', data.timestamp, eid, next);
|
db.sortedSetsAdd([
|
||||||
},
|
'events:time',
|
||||||
function (next) {
|
'events:time:' + data.type,
|
||||||
db.sortedSetAdd('events:time:' + data.type, data.timestamp, eid, next);
|
], data.timestamp, eid, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.setObject('event:' + eid, data, next);
|
db.setObject('event:' + eid, data, next);
|
||||||
|
|||||||
@@ -261,19 +261,12 @@ module.exports = function (Topics) {
|
|||||||
if (!parseInt(mainPid, 10)) {
|
if (!parseInt(mainPid, 10)) {
|
||||||
Topics.setTopicField(tid, 'mainPid', postData.pid, next);
|
Topics.setTopicField(tid, 'mainPid', postData.pid, next);
|
||||||
} else {
|
} else {
|
||||||
async.parallel([
|
const upvotes = parseInt(postData.upvotes, 10) || 0;
|
||||||
function (next) {
|
const downvotes = parseInt(postData.downvotes, 10) || 0;
|
||||||
db.sortedSetAdd('tid:' + tid + ':posts', postData.timestamp, postData.pid, next);
|
const votes = upvotes - downvotes;
|
||||||
},
|
db.sortedSetsAdd([
|
||||||
function (next) {
|
'tid:' + tid + ':posts', 'tid:' + tid + ':posts:votes',
|
||||||
var upvotes = parseInt(postData.upvotes, 10) || 0;
|
], [postData.timestamp, votes], postData.pid, next);
|
||||||
var downvotes = parseInt(postData.downvotes, 10) || 0;
|
|
||||||
var votes = upvotes - downvotes;
|
|
||||||
db.sortedSetAdd('tid:' + tid + ':posts:votes', votes, postData.pid, next);
|
|
||||||
},
|
|
||||||
], function (err) {
|
|
||||||
next(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ module.exports = function (User) {
|
|||||||
db.incrObjectField('global', 'userCount', next);
|
db.incrObjectField('global', 'userCount', next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetAdd('username:uid', userData.uid, userData.username, next);
|
db.sortedSetsAdd([
|
||||||
|
'username:uid', 'user:' + userData.uid + ':usernames',
|
||||||
|
], [userData.uid, timestamp], userData.username, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetAdd('username:sorted', 0, userData.username.toLowerCase() + ':' + userData.uid, next);
|
db.sortedSetAdd('username:sorted', 0, userData.username.toLowerCase() + ':' + userData.uid, next);
|
||||||
@@ -92,9 +94,6 @@ module.exports = function (User) {
|
|||||||
function (next) {
|
function (next) {
|
||||||
db.sortedSetsAdd(['users:postcount', 'users:reputation'], 0, userData.uid, next);
|
db.sortedSetsAdd(['users:postcount', 'users:reputation'], 0, userData.uid, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
|
||||||
db.sortedSetAdd('user:' + userData.uid + ':usernames', timestamp, userData.username, next);
|
|
||||||
},
|
|
||||||
function (next) {
|
function (next) {
|
||||||
groups.join('registered-users', userData.uid, next);
|
groups.join('registered-users', userData.uid, next);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user