Skip to content

feat: add pagination for oauth client list endpoint#2552

Open
cemalkilic wants to merge 3 commits into
masterfrom
cemal/feat-add-pagination-oauth-clients-list
Open

feat: add pagination for oauth client list endpoint#2552
cemalkilic wants to merge 3 commits into
masterfrom
cemal/feat-add-pagination-oauth-clients-list

Conversation

@cemalkilic
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature

What is the current behavior?

Resolves the TODO in OAuthServerClientListm now mirrors the /admin/users pagination behaviour (page/per_page query params, Link and X-Total-Count response headers).

Moves the paginate/addPaginationHeaders helpers into internal/api/shared so both the api and oauthserver packages can use them without a circular import.

@cemalkilic cemalkilic requested a review from a team as a code owner May 28, 2026 09:48
var clients []models.OAuthServerClient
if err := db.Q().Where("deleted_at is null").Order("created_at desc").All(&clients); err != nil {
q := db.Q().Where("deleted_at is null").Order("created_at desc")
if err := q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&clients); err != nil { // #nosec G115
var clients []models.OAuthServerClient
if err := db.Q().Where("deleted_at is null").Order("created_at desc").All(&clients); err != nil {
q := db.Q().Where("deleted_at is null").Order("created_at desc")
if err := q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&clients); err != nil { // #nosec G115
Copy link
Copy Markdown
Contributor

@fadymak fadymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments. I'm a bit hesitant about proliferating the use of limit-offest-based pagination and including the total count given the performance on larger tables (the total count being the more concerning one).

For now, it looks like we only use pagination on GET /admin/users and GET /admin/audit — perhaps it's worth the inconsistency to start to move away from the total count (and potentially to cursor-based pagination)?

Comment thread internal/api/pagination.go Outdated
Comment thread internal/api/shared/pagination.go
Comment thread internal/api/shared/pagination.go
Comment thread internal/api/shared/pagination.go Outdated
Comment thread internal/api/oauthserver/handlers.go Fixed
Comment thread internal/api/oauthserver/handlers.go Fixed
the bounds added in Paginate() function already tracks them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants