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 memory issue on the student courses reports screen #7468
Conversation
216fa21
to
b86b965
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #7468 +/- ##
============================================
+ Coverage 51.20% 51.26% +0.05%
+ Complexity 11189 11184 -5
============================================
Files 614 614
Lines 47230 47229 -1
Branches 405 405
============================================
+ Hits 24186 24211 +25
+ Misses 22717 22691 -26
Partials 327 327
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
I didn't notice a performance improvement, but I did check that the data was still the same when logged in as an admin or as a teacher. Looking at the code, I guess this should also be tested with HPPS on and off?
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.
LGTM too 👍
Hm, I thought covering it with unit tests should be enough but just in case I did a few more live HPPS tests as well. I'll start adding HPPS test instructions in the future. 👍 |
Resolves #7439
This PR fixes an "out of memory" error on the student courses reports screen on sites with many students.
The main issue was when checking if the current user has access to the student's report screen. For that, the code was fetching the course status for all students for all courses. To make it worse,
WP_Metadata_Lazyloader
tries to fetch all the comment metas at once and fills the memory of the server.Before:
After:
Proposed Changes
Sensei_Teacher::get_learner_ids_for_courses_with_edit_permission
method so it will fetch the needed data in a more efficient way.Sensei_Teacher::get_learner_ids_for_courses_with_edit_permission
method for HPPS. This method is not used on the front-end so the HPPS logic is not in use currently.Sensei_Teacher::get_learner_ids_for_courses_with_edit_permission
for admin users.Testing Instructions
trunk
. For me, the decrease was around 5% because my local database is not that big.Pre-Merge Checklist