Skip to content

Commit fcb7e83

Browse files
committed
Paginate staff users count in content-stats
1 parent b6abe9d commit fcb7e83

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tasks/content-stats.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,17 @@ const getFullTaskList = (options) => {
144144
{
145145
title: 'Counting staff',
146146
task: async (ctx) => {
147-
const usersData = await ctx.api.users.browse({limit: 'all', include: 'roles,count.posts'});
147+
let usersData = [];
148+
let page = 1;
149+
let lastResponse;
150+
151+
do {
152+
lastResponse = await ctx.api.users.browse({limit: 100, page, include: 'roles,count.posts'});
153+
usersData = usersData.concat(lastResponse);
154+
page = lastResponse.meta.pagination.next;
155+
} while (lastResponse.meta.pagination.next);
156+
157+
usersData.meta = lastResponse.meta;
148158

149159
const staffOwner = usersData.filter(word => word.roles[0].name === 'Owner');
150160
const staffAdministrator = usersData.filter(word => word.roles[0].name === 'Administrator');

0 commit comments

Comments
 (0)