feat: add pagination to groups page, api routes

use page instead of after
This commit is contained in:
Barış Soner Uşaklı
2024-11-24 11:36:02 -05:00
parent 6f083259c1
commit 49e0e1ab2d
8 changed files with 95 additions and 92 deletions

View File

@@ -13,8 +13,9 @@ const slugify = require('../slugify');
const groupsAPI = module.exports;
groupsAPI.list = async (caller, data) => {
const groupsPerPage = 10;
const start = parseInt(data.after || 0, 10);
const page = parseInt(data.page, 10) || 1;
const groupsPerPage = 15;
const start = Math.max(0, page - 1) * groupsPerPage;
const stop = start + groupsPerPage - 1;
const groupData = await groups.getGroupsBySort(data.sort, start, stop);