mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 01:45:47 +01:00
performance improvements (#8795)
* perf: nconf/winston/render cache nconf.get calls modify middleware.pageView to call next earlier don't call winston.verbose on every hook see https://github.com/winstonjs/winston/issues/1669 translate header/footer separately and cache results for guests * fix: copy paste fail * refactor: style and fire hook only log in dev mode * fix: cache key, header changes based on template * perf: change replace * fix: add missing await * perf: category * perf: lodash clone * perf: remove escapeRegexChars
This commit is contained in:
committed by
GitHub
parent
822c13f199
commit
a05905f196
@@ -62,7 +62,14 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
uid = options.uid;
|
||||
}
|
||||
|
||||
let topics = await Topics.getTopicsData(tids);
|
||||
const [tags, topics, hasRead, isIgnored, bookmarks, callerSettings] = await Promise.all([
|
||||
Topics.getTopicsTagsObjects(tids),
|
||||
Topics.getTopicsData(tids),
|
||||
Topics.hasReadTopics(tids, uid),
|
||||
Topics.isIgnoring(tids, uid),
|
||||
Topics.getUserBookmarks(tids, uid),
|
||||
user.getSettings(uid),
|
||||
]);
|
||||
|
||||
const uids = _.uniq(topics.map(t => t && t.uid && t.uid.toString()).filter(v => utils.isNumber(v)));
|
||||
const cids = _.uniq(topics.map(t => t && t.cid && t.cid.toString()).filter(v => utils.isNumber(v)));
|
||||
@@ -72,26 +79,16 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
return await Promise.all(guestTopics.map(topic => posts.getPostField(topic.mainPid, 'handle')));
|
||||
}
|
||||
const [
|
||||
callerSettings,
|
||||
users,
|
||||
userSettings,
|
||||
categoriesData,
|
||||
hasRead,
|
||||
isIgnored,
|
||||
bookmarks,
|
||||
teasers,
|
||||
tags,
|
||||
guestHandles,
|
||||
] = await Promise.all([
|
||||
user.getSettings(uid),
|
||||
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status']),
|
||||
user.getMultipleUserSettings(uids),
|
||||
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'backgroundImage', 'imageClass', 'bgColor', 'color', 'disabled']),
|
||||
Topics.hasReadTopics(tids, uid),
|
||||
Topics.isIgnoring(tids, uid),
|
||||
Topics.getUserBookmarks(tids, uid),
|
||||
Topics.getTeasers(topics, options),
|
||||
Topics.getTopicsTagsObjects(tids),
|
||||
loadGuestHandles(),
|
||||
]);
|
||||
|
||||
@@ -128,9 +125,9 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
}
|
||||
});
|
||||
|
||||
topics = topics.filter(topic => topic && topic.category && !topic.category.disabled);
|
||||
const filteredTopics = topics.filter(topic => topic && topic.category && !topic.category.disabled);
|
||||
|
||||
const result = await plugins.fireHook('filter:topics.get', { topics: topics, uid: uid });
|
||||
const result = await plugins.fireHook('filter:topics.get', { topics: filteredTopics, uid: uid });
|
||||
return result.topics;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user