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; const { user: userService } = this.dtp.services;
try { try {
res.locals.pagination = this.getPaginationParameters(req, 20); 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'); res.render('post/author/all');
} catch (error) { } catch (error) {
return next(error); return next(error);

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

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