ion
ion copied to clipboard
fix: add values_list("token, "expires") to reduce csl apps load time (closes Issue #1663)
Proposed changes
- Add
values_list("token, "expires")in between.order_by("-expires")and.first()
Brief description of rationale
Instead of retrieving all of the fields from the AccessToken object (which leads to slower load times), only retrieve necessary fields to filter the most recent Token. In turn, this will improve the load time of CSL apps.
#1663
coverage: 79.467% (+0.02%) from 79.447% when pulling be3270dddcc91e5d17320b631b754c13924a86db on devsrivv:dev into 02c1bd44585eb1e4d4abeac7223365d6a7fefb6e on tjcsl:dev.
Hey Justin, I can't figure out a way to practically measure the speed of this change in my dev environment as the links lead to CSL apps of the actual ion (signed in to my account instead of the test account). However, I tested the change in my dev environment and I can confirm that it functions.
Originally, the query filtered through all 10 fields id, user, source_refresh_token, token, id_token, application, expires, scope, created, updated from oauth2_provider.models.AccessToken
I made it so that it only queries the token and expires fields along with the necessary user and application fields so that it saves time (reducing the size from 10 fields to 4 fields), which theoretically saves 60% more time.
Does the logic behind my solution make sense? If not, is there any way to check the issue in my dev environment? Thanks
I'm not sure values_list saves time here, which is why a quantitative measurement is needed. It seems to me what's taking a long time is filtering through the AccessToken model, not accessing the fields, but maybe your solution works. You could create your own OAuth application to test the timing. Have you done the Django blog assignment? That would work.