Repository navigation
Paginate /api/user/all and stop the N+1 recipient loads (sfind-cf43a4da) - #364
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes code-scan finding sfind-cf43a4da.
GET /api/user/allused to load everyUser. Serializing that list then lazy-loadedrecipientListanduserRolesonce per user, plus each user's accounts.GET /api/user/all?page=0&size=50(default 50, max 200, sorted byuserId; out-of-range values return 400). The response body is still a plain JSON array, so existing callers keep working. Totals go in theX-Total-Count,X-Page,X-Page-SizeandX-Total-Pagesheaders, whichRequestFilternow exposes viaAccess-Control-Expose-Headers.UserDao.findAll(Pageable)uses@EntityGraph(attributePaths = {"primaryAccount","savingsAccount"}, type = LOAD), so accounts are join-fetched into the single page query.UserService.findUserList()is nowfindUserList(Pageable). The unboundedList<User> findAll()is removed.@JsonIgnoreonUser.recipientList, matchingappointmentList. The admin screen never shows recipients.@BatchSize(size = 200)on the EAGERuserRoles.userRolesquery per user. With LOAD it runs one batchedIN (...)query.UserService.getUsers(page, size)and a Previous/Next pager inuser-account.componentdriven byX-Total-Pages.Measured against MySQL 5.7 with 121 seeded users, 3 recipients each, counting
spring.jpa.show-sqlstatements per request:GET /api/user/allLIMIT, count, batched roles)Verification
UserResourceTest(standalone MockMvc + Mockito, 4 tests) covers the defaults and totals headers, passing page/size through, 400s for out-of-range values, and thatrecipientListis not serialized. It passes against the Boot 1.5-era jars (Spring 4.3.12, spring-data-commons 1.13.8), compiled withjavac --release 8and run throughJUnitCore.PageRequest.ofinstead ofnew PageRequest,findByIdinAppointmentServiceImpl,mysql-connector-j), logged in as an admin over HTTP.mvn teston the real Boot 1.5.4 build: the 1.5.4 parent isn't cached and Maven Central is blocked in this session.node_modules, and the npm registry is blocked, so it wasn't built or exercised in a browser.Related
UserSummaryDTO + password-hash@JsonIgnore) and older migration PRs feature: migrate UserFront to Spring Boot 4.1.1 / Java 21 and AdminPortal to Angular 22 #111/feature: WS5 JPA/Hibernate 7 entity validation #116/COG-1150: W1 · User + UserRole GenerationType.IDENTITY and @JsonIgnore on recipientList #341 also put@JsonIgnoreonrecipientList. None of them paginate the endpoint. If both this PR and bug: stop exposing User password hash via admin JSON APIs and toString #123 land, the controller signatures need a merge.user-account.component.ts(res.json(), in-place enable/disable). Expect a small conflict there.Written by Devin
Devin-Org: engineering
Open in Devin Desktop: https://app.devin.ai/desktop/session/7e2990c52edb4f878983ffb32de62260?variant=devin
Devin Review