-
Notifications
You must be signed in to change notification settings - Fork 37
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
Improve Performance for monthly active users API endpoint #234
Conversation
Codecov Report
@@ Coverage Diff @@
## master #234 +/- ##
==========================================
+ Coverage 91.30% 91.36% +0.05%
==========================================
Files 39 40 +1
Lines 1956 1968 +12
==========================================
+ Hits 1786 1798 +12
Misses 170 170
Continue to review full report at Codecov.
|
4eee541
to
fdb04b4
Compare
figures/metrics.py
Outdated
""" | ||
month_for = datetime.datetime.utcnow() | ||
site_sm = figures.sites.get_student_modules_for_site(site) | ||
curr_sm = site_sm.filter(modified__year=month_for.year, | ||
modified__month=month_for.month) | ||
return curr_sm.values('student__id').distinct().count() | ||
return curr_sm.values('student__id').distinct() |
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.
We do this so we're able to use this function to retrieve the distinct ids, then we can get the count from the querset for when we need the count
fdb04b4
to
21d88df
Compare
This comment has been minimized.
This comment has been minimized.
@OmarIthawi I didn't need to do the 3rd commit, which was going to update the viewset. Switching logic at I'll revise the git commit message |
Thanks Omar! |
The purpose of this is to improve API performance. Figures currently performs a live query on the `edx-platform` `courseware.models.StudentModule` model, but the query is too slow when there are many `StudentModule` records. The rough order of magnitude (ROM) for "many" appears to be about 10^6. The slow query causes an API timeout, degrading performance for Figures UI. This commit provides the storage for this metric so the following commit can update the pipeline code and metrics code
The purpose of this is to improve API performance. See the previous commit with SHA 92ea8c4 for an explanation. This commit adds the pipeline code to populate 'SiteDailyMetrics.mau' with the latest numbers for the month as of yesterday We also clean up the old live MAU collection from StudentModule, removing dead coe and the tests that call the dead code
21d88df
to
887f28e
Compare
This PR is to improve the performance of Figures API to improve Figures UI page loading and prevent timeouts on retrieving monthly active users, which gets slow as we're currently pulling live data for the current month
Figures currently performs a live query on the
edx-platform
courseware.models.StudentModule
model, but the query is too slow when there are manyStudentModule
records. The rough order of magnitude (ROM) for "many" appears to be about 10^6.There are two commits.
The data model update adds 'mau' field to 'SiteDailyMetrics' model
The pipeline code now populates 'SiteDailyMetrics.mau' field with the latest numbers for the month as of when the pipeline is run.
The slow query causes an API timeout, degrading performance for Figures UI.
This commit provides the storage for this metric so the following commit can update the pipeline code and the 3rd commit to update the API code
Removed the old MAU calculation code which is now dead code and removed the tests