mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
single call to get slug and postcount
This commit is contained in:
@@ -31,14 +31,11 @@ topicsController.get = function(req, res, next) {
|
|||||||
privileges: function(next) {
|
privileges: function(next) {
|
||||||
privileges.topics.get(tid, uid, next);
|
privileges.topics.get(tid, uid, next);
|
||||||
},
|
},
|
||||||
postCount: function(next) {
|
|
||||||
topics.getPostCount(tid, next);
|
|
||||||
},
|
|
||||||
settings: function(next) {
|
settings: function(next) {
|
||||||
user.getSettings(uid, next);
|
user.getSettings(uid, next);
|
||||||
},
|
},
|
||||||
slug: function(next) {
|
topic: function(next) {
|
||||||
topics.getTopicField(tid, 'slug', next);
|
topics.getTopicFields(tid, ['slug', 'postcount'], next);
|
||||||
}
|
}
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
@@ -50,7 +47,7 @@ topicsController.get = function(req, res, next) {
|
|||||||
return categoriesController.notFound(req, res);
|
return categoriesController.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tid + '/' + req.params.slug !== results.slug) {
|
if (tid + '/' + req.params.slug !== results.topic.slug) {
|
||||||
return categoriesController.notFound(req, res);
|
return categoriesController.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ topicsController.get = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var settings = results.settings;
|
var settings = results.settings;
|
||||||
var postCount = parseInt(results.postCount, 10);
|
var postCount = parseInt(results.topic.postcount, 10);
|
||||||
var pageCount = Math.ceil((postCount - 1) / settings.postsPerPage);
|
var pageCount = Math.ceil((postCount - 1) / settings.postsPerPage);
|
||||||
|
|
||||||
if (utils.isNumber(req.params.post_index)) {
|
if (utils.isNumber(req.params.post_index)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user