Skip to content

Commit

Permalink
CB/bp: Fix team members API endpoint pagination (go-gitea#24754)
Browse files Browse the repository at this point in the history
Now it's 1-based instead of 0-based

- Fixes go-gitea#24747

![image](https://github.com/go-gitea/gitea/assets/20454870/9b58ecfa-666c-4b78-bd0f-93233efeecbd)

![image](https://github.com/go-gitea/gitea/assets/20454870/103b767a-e02e-4473-9f9f-5a676a61c174)

Previous API consumers may have relied on the 0-based pagination of this
endpoint. The page numbering now starts at 1, as documented.

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
  • Loading branch information
yardenshoham authored and Otto Richter committed Jul 5, 2023
1 parent 12b722a commit 1102526
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/organization/team_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func GetTeamMembers(ctx context.Context, opts *SearchMembersOptions) ([]*user_mo
Where(builder.Eq{"team_id": opts.TeamID}),
)
}
if opts.PageSize > 0 && opts.Page > -1 {
sess = sess.Limit(opts.PageSize, opts.Page*opts.PageSize)
if opts.PageSize > 0 && opts.Page > 0 {
sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
}
if err := sess.OrderBy("full_name, name").Find(&members); err != nil {
return nil, err
Expand Down

0 comments on commit 1102526

Please sign in to comment.