Skip to content

Fixed pagination start value #1344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Flux<OrgMember> getOrganizationMembers(String orgId) {

@Override
public Flux<OrgMember> getOrganizationMembers(String orgId, int page, int count) {
return biRelationService.getBySourceId(ORG_MEMBER, orgId, PageRequest.of(page, count))
return biRelationService.getBySourceId(ORG_MEMBER, orgId, PageRequest.of(page - 1, count))
.map(OrgMember::from);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Mono<GroupMemberAggregateView> getGroupMembers(String groupId, int page,
.filter(Objects::nonNull)
.toList();
var pageTotal = list.size();
list = list.subList(page * count, Math.min(page * count + count, pageTotal));
list = list.subList((page - 1) * count, count == 0 ? pageTotal : Math.min(page * count, pageTotal));
return Pair.of(list, pageTotal);
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public Mono<GroupListResponseView<List<GroupView>>> getOrgGroups(@RequestParam(r
.filter(orgMember -> !orgMember.isAdmin() && !orgMember.isSuperAdmin() &&
devMembers.stream().noneMatch(devMember -> devMember.getUserId().equals(orgMember.getUserId()))).toList().size();

var subList = groupList.subList((pageNum - 1) * pageSize, pageSize <= 0?groupList.size():pageNum * pageSize);
var subList = groupList.subList((pageNum - 1) * pageSize, pageSize <= 0?groupList.size():Math.min(pageNum * pageSize, groupList.size()));
return new GroupListResponseView<>(ResponseView.SUCCESS,
"",
subList,
totalAdmins,
totalAdminsAndDevelopers,
totalDevelopersOnly,
totalOtherMembers,
subList.size(),
groupList.size(),
pageNum,
pageSize);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Mono<OrgMemberListView> getOrgMemberListView(String orgId, int page, int
.filter(Objects::nonNull)
.collect(Collectors.toList());
var pageTotal = list.size();
list = list.subList(page * count, Math.min(page * count + count, pageTotal));
list = list.subList((page - 1) * count, count == 0 ? pageTotal : Math.min(page * count, pageTotal));
return Pair.of(list, pageTotal);
});
})
Expand Down