mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: show analytics data page by page
This commit is contained in:
1 parent
9200336b49
commit
ac31ca8659
9 files changed
+87
-12
No files matched your search
@@ -11,7 +11,9 @@ export function userCount() {
|
||||
return User.find().count()
|
||||
}
|
||||
|
||||
export async function userList() {
|
||||
export async function userList(pageNumber, itemsPerPage) {
|
||||
const skipAmount = (pageNumber - 1) * itemsPerPage
|
||||
|
||||
const users = await Session.aggregate([
|
||||
{
|
||||
$group: {
|
||||
@@ -30,7 +32,10 @@ export async function userList() {
|
||||
},
|
||||
{ $unwind: '$userData' },
|
||||
{ $sort: { 'userData.createdAt': 1 } },
|
||||
{ $skip: skipAmount },
|
||||
{ $limit: itemsPerPage },
|
||||
])
|
||||
|
||||
return users.map(({ userData, count, lastActivityAt }) => {
|
||||
const { username, email, createdAt } = userData
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user