mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #2587
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
db = require('../database'),
|
db = require('../database'),
|
||||||
|
|
||||||
|
user = require('../user'),
|
||||||
plugins = require('../plugins');
|
plugins = require('../plugins');
|
||||||
|
|
||||||
|
|
||||||
@@ -77,13 +78,19 @@ module.exports = function(Topics) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
db.sortedSetsRemove([
|
db.sortedSetsRemove([
|
||||||
'cid:' + topicData.cid + ':tids',
|
'cid:' + topicData.cid + ':tids',
|
||||||
'cid:' + topicData.cid + ':tids:posts',
|
'cid:' + topicData.cid + ':tids:posts',
|
||||||
'cid:' + topicData.cid + ':uid:' + topicData.uid + ':tids',
|
'cid:' + topicData.cid + ':uid:' + topicData.uid + ':tids',
|
||||||
'uid:' + topicData.uid + ':topics'
|
'uid:' + topicData.uid + ':topics'
|
||||||
], tid, callback);
|
], tid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
user.decrementUserFieldBy(topicData.uid, 'topiccount', 1, next);
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ var db = require('./database'),
|
|||||||
schemaDate, thisSchemaDate,
|
schemaDate, thisSchemaDate,
|
||||||
|
|
||||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||||
latestSchema = Date.UTC(2015, 0, 14);
|
latestSchema = Date.UTC(2015, 0, 15);
|
||||||
|
|
||||||
Upgrade.check = function(callback) {
|
Upgrade.check = function(callback) {
|
||||||
db.get('schemaDate', function(err, value) {
|
db.get('schemaDate', function(err, value) {
|
||||||
@@ -630,8 +630,45 @@ Upgrade.upgrade = function(callback) {
|
|||||||
winston.info('[2015/01/14] Upgrading follow sets to sorted sets skipped');
|
winston.info('[2015/01/14] Upgrading follow sets to sorted sets skipped');
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
thisSchemaDate = Date.UTC(2015, 0, 15);
|
||||||
|
if (schemaDate < thisSchemaDate) {
|
||||||
|
winston.info('[2015/01/15] Creating topiccount for users');
|
||||||
|
|
||||||
|
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
|
||||||
|
if (err) {
|
||||||
|
winston.error('[2014/01/15] Error encountered while Creating topiccount for users');
|
||||||
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async.eachLimit(uids, 50, function(uid, next) {
|
||||||
|
db.sortedSetCard('uid:' + uid + ':topics', function(err, count) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(count, 10)) {
|
||||||
|
db.setObjectField('user:' + uid, 'topiccount', count, next);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(err) {
|
||||||
|
if (err) {
|
||||||
|
winston.error('[2015/01/15] Error encountered while Creating topiccount for users');
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
winston.info('[2015/01/15] Creating topiccount for users done');
|
||||||
|
Upgrade.update(thisSchemaDate, next);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
winston.info('[2015/01/15] Creating topiccount for users skipped');
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Add new schema updates here
|
// Add new schema updates here
|
||||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 22!!!
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 22!!!
|
||||||
], function(err) {
|
], function(err) {
|
||||||
|
|||||||
@@ -287,7 +287,10 @@ var async = require('async'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.addTopicIdToUser = function(uid, tid, timestamp, callback) {
|
User.addTopicIdToUser = function(uid, tid, timestamp, callback) {
|
||||||
db.sortedSetAdd('uid:' + uid + ':topics', timestamp, tid, callback);
|
async.parallel([
|
||||||
|
async.apply(db.sortedSetAdd, 'uid:' + uid + ':topics', timestamp, tid),
|
||||||
|
async.apply(User.incrementUserFieldBy, uid, 'topiccount', 1)
|
||||||
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
User.exists = function(userslug, callback) {
|
User.exists = function(userslug, callback) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ module.exports = function(User) {
|
|||||||
'profileviews': 0,
|
'profileviews': 0,
|
||||||
'reputation': 0,
|
'reputation': 0,
|
||||||
'postcount': 0,
|
'postcount': 0,
|
||||||
|
'topiccount': 0,
|
||||||
'lastposttime': 0,
|
'lastposttime': 0,
|
||||||
'banned': 0,
|
'banned': 0,
|
||||||
'status': 'online'
|
'status': 'online'
|
||||||
|
|||||||
Reference in New Issue
Block a user