mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-10 20:11:45 +02:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
@@ -257,28 +257,25 @@ var db = require('./database'),
|
||||
}
|
||||
|
||||
CategoryTools.privileges(cid, uid, function(err, privileges) {
|
||||
if (privileges.read) {
|
||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
||||
|
||||
if (err) {
|
||||
winston.err(err);
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
if (pids.length === 0) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids(pids, true, function(err, postData) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, postData);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
callback(null, []);
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!privileges.read) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {
|
||||
if (err) {
|
||||
return callback(err, []);
|
||||
}
|
||||
|
||||
if (!pids || !pids.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids(pids, true, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -291,21 +288,16 @@ var db = require('./database'),
|
||||
|
||||
db.sortedSetRemove('categories:recent_posts:cid:' + oldCid, pid);
|
||||
db.sortedSetAdd('categories:recent_posts:cid:' + cid, timestamp, pid);
|
||||
callback(null);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
topics.getPids(tid, function(err, pids) {
|
||||
if(err) {
|
||||
return callback(err, null);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.each(pids, movePost, function(err) {
|
||||
if(err) {
|
||||
return callback(err, null);
|
||||
}
|
||||
callback(null, 1);
|
||||
});
|
||||
async.each(pids, movePost, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -206,19 +206,14 @@ var winston = require('winston'),
|
||||
|
||||
topics.setTopicField(tid, 'cid', cid);
|
||||
|
||||
categories.moveActiveUsers(tid, oldCid, cid);
|
||||
categories.moveRecentReplies(tid, oldCid, cid, function(err, data) {
|
||||
if (err) {
|
||||
winston.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
if(!parseInt(topic.deleted, 10)) {
|
||||
categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1);
|
||||
categories.incrementCategoryFieldBy(cid, 'topic_count', 1);
|
||||
}
|
||||
|
||||
callback(null);
|
||||
categories.moveActiveUsers(tid, oldCid, cid);
|
||||
|
||||
categories.moveRecentReplies(tid, oldCid, cid, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ var db = require('./database'),
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
var latestSchema = new Date(2014, 1, 2, 16, 0).getTime();
|
||||
var latestSchema = new Date(2014, 1, 7, 16, 0).getTime();
|
||||
|
||||
db.get('schemaDate', function(err, value) {
|
||||
if (parseInt(value, 10) >= latestSchema) {
|
||||
@@ -515,6 +515,52 @@ Upgrade.upgrade = function(callback) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
|
||||
thisSchemaDate = new Date(2014, 1, 7, 16, 0).getTime();
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
|
||||
winston.info('[2014/2/7] Updating category recent replies');
|
||||
db.getListRange('categories:cid', 0, -1, function(err, cids) {
|
||||
|
||||
function updateCategory(cid, next) {
|
||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, - 1, function(err, pids) {
|
||||
function updatePid(pid, next) {
|
||||
Posts.getCidByPid(pid, function(err, realCid) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if(parseInt(realCid, 10) !== parseInt(cid, 10)) {
|
||||
Posts.getPostField(pid, 'timestamp', function(err, timestamp) {
|
||||
db.sortedSetRemove('categories:recent_posts:cid:' + cid, pid);
|
||||
db.sortedSetAdd('categories:recent_posts:cid:' + realCid, timestamp, pid);
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async.each(pids, updatePid, next);
|
||||
});
|
||||
}
|
||||
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
async.each(cids, updateCategory, next);
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
winston.info('[2014/2/7] Updating category recent replies -- skipped');
|
||||
next();
|
||||
}
|
||||
}
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!
|
||||
], function(err) {
|
||||
|
||||
Reference in New Issue
Block a user