-
Notifications
You must be signed in to change notification settings - Fork 301
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
Development
: Reduce fetched data for get competency endpoint
#7460
Conversation
""") | ||
Optional<Competency> findByIdWithExercisesAndLectureUnits(@Param("competencyId") Long competencyId); | ||
@EntityGraph(type = LOAD, attributePaths = { "userProgress", "lectureUnits.completedUsers" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this EntityGraph
really needed? I think we want to avoid loading all lectureUnits.completedUsers
Can you not simply use left join fetch as above but add a WHERE clause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fetching all data is prevented by joining on userId
. Adding this to the WHERE clause would incorrectly return the competency only when a progress entity for the user exists. If not, the query would not find it and return empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use LEFT JOIN FETCH ... ON
in the query instead of the entity graph?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I tried at first. It's not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment above? I think the statement is not fully clear otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--> follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on ts1. Everything seems to still work fine. Response now only contains one userProgress element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed Query LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS1, the request only returns my own progress. LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on ts1, everything works & request only returns my data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually tested on a legacy server. Everything works as despribed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual tested on legacy server ts2. Problems with the student view.
As a student (tried with different test accounts) I saw the "Edit" button and even came to the "Edit a competency" page. There I got the message "You are not authorized" and I couldn't change anything but I don't think a student user should see it. I tried this in different courses and it is always the same. The student user can even see the "Competency Management" page
Please let me know if this has anything to do with your PR.
Checklist
General
Server
Motivation and Context
Currently the endpoint
getCompetency(long)
fetches data for all users. This PR reduces the fetched data to only contain information related to the user sending the request, i.e. it excludes any other users' progress enteties.Description
Optimized query to only fetch user related data.
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Review Progress
Performance Review
Code Review
Manual Tests
Test Coverage