Repository navigation
bug: page /api/appointment/all and return AppointmentSummary DTOs (N+1 + unbounded list) - #363
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
…x N+1 + unbounded list)
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-b69c72a5 (high). Before this change,
GET /api/appointment/allreturnedappointmentDao.findAll(): every row, each with its EAGERUserserialized. ThatUserincluded the password hash and the lazyrecipientList, which costs one extra SELECT per user while JSON is written (open-session-in-view).The endpoint now runs one paged JPQL constructor projection plus a count query:
{id, date, location, description, confirmed, user: {username}}. The response no longer includes the password, recipients, accounts or roles.Appointment.useris now@ManyToOne(fetch = LAZY)+@JsonIgnore. No other code path reads it (AppointmentControlleronly sets it).AppointmentService.findAll()is replaced byfindAllSummaries(Pageable). It had no other callers.RequestFilteraddsAccess-Control-Expose-Headers: X-Total-Count, X-Page, X-Page-Sizeso the Angular app on :4200 can read the total.page/size(50) and adds a Newer/Older pager driven byX-Total-Count. Behavior change: without the pager, admins would see only the 50 newest appointments.h2is added at test scope for the new@DataJpaTest.Measured with H2, 30 users, each with 1 appointment and 1 recipient:
findAll()+ JacksonfindAllSummaries(page 0, size 10)Tests
AppointmentResourceTest(Mockito + standalone MockMvc): paging headers and DTO JSON shape (nouser.passwordoruser.recipientList), default page/size, newest-first sort, and 400 for size>200, size 0, page -1 and a non-numeric page.AppointmentDaoTest(@DataJpaTest, Hibernate statistics): one page costs exactly 2 prepared statements, ordering is correct, and the serialized JSON has no hash or recipients.How it was verified / limits: this repo has no CI. The Boot 1.5.4 parent can't be resolved offline (Maven Central is blocked in-session), so
mvn testwas not run. Instead, the touched classes and both tests were compiled (javac --release 8) and run with JUnitCore on a harness classpath: cached Boot 1.5.8 starters (web, data-jpa, test), H2 1.4.197 and spring-security-core. All 4 tests passed. The AdminPortal changes were not built or linted: there is nonode_modules, and the npm registry is blocked.Overlap
Older open PR #123 adds an
AppointmentSummaryDTO for the password-hash finding, but without paging or the query fix. #70, #26 and #336 touch the same resource for HTTP-method changes. Expect small merge conflicts inAppointmentResource; only one DTO approach should land.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/8f834a5573cc498dbb9b9bdf55b6b1ae
Open in Devin Desktop: https://app.devin.ai/desktop/session/8f834a5573cc498dbb9b9bdf55b6b1ae?variant=devin
Devin Review