Skip to content
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

fix: do not omit last page on identity list #3169

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

zepatrik
Copy link
Member

The problem is that the persister uses 1 as the fist page, while the pagination header helper assumes 0 is the first page. Therefore, until now, the second-last page was considered the last and no next rel was set in the Link header.

This is the only way I could think of to make this not a breaking change, but it is super ugly.

@zepatrik zepatrik requested a review from aeneasr as a code owner March 15, 2023 15:45
@@ -180,7 +180,7 @@ func (h *Handler) list(w http.ResponseWriter, r *http.Request, _ httprouter.Para
isam[i] = WithCredentialsMetadataAndAdminMetadataInJSON(identity)
}

migrationpagination.PaginationHeader(w, urlx.AppendPaths(h.r.Config().SelfAdminURL(r.Context()), RouteCollection), total, page, itemsPerPage)
migrationpagination.PaginationHeader(w, urlx.AppendPaths(h.r.Config().SelfAdminURL(r.Context()), RouteCollection), total+int64(itemsPerPage), page, itemsPerPage)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a super ugly hack, please suggest a better way if you know any. page-1 does not work because then we get 1 as the next page for 1.

Copy link
Member

@jonas-jonas jonas-jonas Mar 16, 2023

Choose a reason for hiding this comment

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

Why is this necessary? Doesn't that value come from the DB?

Ah, nvm.

Copy link
Member

Choose a reason for hiding this comment

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

This breaks the x-total-count unfortunately.

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #3169 (5679c0e) into master (b9ccccf) will decrease coverage by 0.09%.
The diff coverage is 100.00%.

❗ Current head 5679c0e differs from pull request most recent head 3b65641. Consider uploading reports for the commit 3b65641 to get more accurate results

@@            Coverage Diff             @@
##           master    #3169      +/-   ##
==========================================
- Coverage   77.71%   77.62%   -0.09%     
==========================================
  Files         317      317              
  Lines       20036    20036              
==========================================
- Hits        15571    15553      -18     
- Misses       3277     3291      +14     
- Partials     1188     1192       +4     
Impacted Files Coverage Δ
identity/handler.go 85.77% <100.00%> (ø)

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@zepatrik zepatrik merged commit f95f48a into master Mar 16, 2023
@zepatrik zepatrik deleted the fix/identity-list-pagination branch March 16, 2023 12:14
aeneasr added a commit that referenced this pull request Mar 23, 2023
aeneasr added a commit that referenced this pull request Mar 23, 2023
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.

None yet

3 participants