changed counting authors from length to DB

master
Andrew Woodlee 2 years ago
parent ed418d1a89
commit 381605414f

@ -397,8 +397,10 @@ class PostController extends SiteController {
const { user: userService } = this.dtp.services;
try {
res.locals.pagination = this.getPaginationParameters(req, 20);
res.locals.authors = await userService.getAuthors(res.locals.pagination);
const {authors , totalAuthorCount }= await userService.getAuthors(res.locals.pagination);
res.locals.authors = authors;
res.locals.totalAuthorCount = totalAuthorCount;
res.render('post/author/all');
} catch (error) {
return next(error);

@ -536,7 +536,9 @@ class UserService extends SiteService {
.limit(pagination.cpp)
.populate(this.populateUser)
.lean();
return authors;
const totalAuthorCount = await User.countDocuments( {'permissions.canAuthorPosts': true } );
return {authors, totalAuthorCount};
}
async getUserProfile (userId) {

@ -13,4 +13,4 @@ block content
li
+renderAuthorCredit(author)
.uk-card-footer
+renderPaginationBar(`/post/authors`, authors.length )
+renderPaginationBar(`/post/authors`, totalAuthorCount )
Loading…
Cancel
Save