Skip to content

Commit 0919cf4

Browse files
authored
correction of pagination handling (#1412)
1 parent c78aafb commit 0919cf4

File tree

1 file changed

+18
-9
lines changed
  • platform/services/account/app/grpc/user

1 file changed

+18
-9
lines changed

platform/services/account/app/grpc/user/find.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,29 @@ func (s *GRPCServer) Find(ctx context.Context, findRequest *pb.FindUserRequest)
404404
}
405405

406406
response.TotalCount = totalCount
407-
const DefaultLimit = 10
408-
nextPageFields := common.CalculateNextPage(response.TotalCount, findRequest.Skip, func() int32 {
407+
408+
if response.TotalMatchedCount == response.TotalCount {
409+
// no pagination needed
410+
nextPage := pb.ListUsersResponse_NextPage{
411+
Skip: 0,
412+
Limit: 0,
413+
}
414+
response.NextPage = &nextPage
415+
} else {
416+
const DefaultLimit = 10
417+
nextPageFields := common.CalculateNextPage(response.TotalCount, findRequest.Skip, func() int32 {
409418
if findRequest.Limit < DefaultLimit {
410419
return DefaultLimit
411420
}
412-
return findRequest.Limit
413-
}())
421+
return findRequest.Limit
422+
}())
414423

415-
nextPage := pb.ListUsersResponse_NextPage{
416-
Skip: nextPageFields.Skip,
417-
Limit: nextPageFields.Limit,
424+
nextPage := pb.ListUsersResponse_NextPage{
425+
Skip: nextPageFields.Skip,
426+
Limit: nextPageFields.Limit,
427+
}
428+
response.NextPage = &nextPage
418429
}
419430

420-
response.NextPage = &nextPage
421-
422431
return &response, nil
423432
}

0 commit comments

Comments
 (0)