mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
formatting - server side core
This commit is contained in:
@@ -6,32 +6,31 @@ var RDB = require('./redis.js'),
|
||||
|
||||
|
||||
function upgradeCategory(cid, callback) {
|
||||
RDB.type('categories:'+ cid +':tid', function(err, type) {
|
||||
RDB.type('categories:' + cid + ':tid', function(err, type) {
|
||||
if (type === 'set') {
|
||||
RDB.smembers('categories:' + cid + ':tid', function(err, tids) {
|
||||
|
||||
function moveTopic(tid, callback) {
|
||||
RDB.hget('topic:' + tid, 'timestamp', function(err, timestamp) {
|
||||
if(err)
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
RDB.zadd('temp_categories:'+ cid + ':tid', timestamp, tid);
|
||||
RDB.zadd('temp_categories:' + cid + ':tid', timestamp, tid);
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
async.each(tids, moveTopic, function(err) {
|
||||
if(!err) {
|
||||
if (!err) {
|
||||
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
||||
callback(null);
|
||||
}
|
||||
else
|
||||
} else
|
||||
callback(err);
|
||||
});
|
||||
|
||||
});
|
||||
} else {
|
||||
winston.info('category already upgraded '+ cid);
|
||||
winston.info('category already upgraded ' + cid);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
@@ -39,54 +38,54 @@ function upgradeCategory(cid, callback) {
|
||||
|
||||
function upgradeUser(uid, callback) {
|
||||
user.getUserFields(uid, ['joindate', 'postcount', 'reputation'], function(err, userData) {
|
||||
if(err)
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
if(userData.joindate)
|
||||
if (userData.joindate)
|
||||
RDB.zadd('users:joindate', userData.joindate, uid, next);
|
||||
else
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
if(userData.postcount)
|
||||
if (userData.postcount)
|
||||
RDB.zadd('users:postcount', userData.postcount, uid, next);
|
||||
else
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
if(userData.reputation)
|
||||
if (userData.reputation)
|
||||
RDB.zadd('users:reputation', userData.reputation, uid, next);
|
||||
else
|
||||
next(null);
|
||||
}
|
||||
], function(err, result) {
|
||||
callback(err);
|
||||
});
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function upgradeUserHash(uid, callback) {
|
||||
user.getUserFields(uid, ['username', 'userslug', 'email'], function(err, userData) {
|
||||
if(err)
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
if(userData.username)
|
||||
if (userData.username)
|
||||
RDB.hset('username:uid', userData.username, uid, next);
|
||||
else
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
if(userData.userslug)
|
||||
if (userData.userslug)
|
||||
RDB.hset('userslug:uid', userData.userslug, uid, next);
|
||||
else
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
if(userData.email)
|
||||
if (userData.email)
|
||||
RDB.hset('email:uid', userData.email, uid, next);
|
||||
else
|
||||
next(null);
|
||||
@@ -135,7 +134,7 @@ exports.upgrade = function() {
|
||||
RDB.lrange('categories:cid', 0, -1, function(err, cids) {
|
||||
|
||||
async.each(cids, upgradeCategory, function(err) {
|
||||
if(!err) {
|
||||
if (!err) {
|
||||
winston.info('upgraded categories');
|
||||
next(null, null);
|
||||
} else {
|
||||
@@ -151,7 +150,7 @@ exports.upgrade = function() {
|
||||
RDB.lrange('userlist', 0, -1, function(err, uids) {
|
||||
|
||||
async.each(uids, upgradeUser, function(err) {
|
||||
if(!err) {
|
||||
if (!err) {
|
||||
winston.info('upgraded users');
|
||||
next(null, null);
|
||||
} else {
|
||||
@@ -165,11 +164,11 @@ exports.upgrade = function() {
|
||||
function upgradeUserHashes(next) {
|
||||
winston.info('upgrading user hashes');
|
||||
RDB.zrange('users:joindate', 0, -1, function(err, uids) {
|
||||
if(err)
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
async.each(uids, upgradeUserHash, function(err) {
|
||||
if(!err) {
|
||||
if (!err) {
|
||||
winston.info('upgraded user hashes');
|
||||
next(null, null);
|
||||
} else {
|
||||
@@ -183,7 +182,7 @@ exports.upgrade = function() {
|
||||
];
|
||||
|
||||
async.series(schema, function(err, results) {
|
||||
if(!err)
|
||||
if (!err)
|
||||
winston.info('upgrade complete');
|
||||
else
|
||||
winston.err(err);
|
||||
|
||||
Reference in New Issue
Block a user