-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Optimizations and UX improvements to the dashboard screen #5637
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
Optimizations and UX improvements to the dashboard screen #5637
Conversation
- No longer show how many builds a project has This is expensive and not very useful - Instead, show the date of the last build - Fixes a performance issue affecting the corporate site
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.
Looks good to me!
Although I left some comments, feel free to merge ;)
readthedocs/projects/querysets.py
Outdated
|
||
# Prefetch the latest build for each project. | ||
subquery = Subquery( | ||
Build.objects.filter(project=OuterRef('project_id')).values_list('id', flat=True)[:1] |
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 think it's not needed because ordering = ['-date']
in the model, but just in case: don't we need to order_by
here?
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.
It isn't necessary due to the default ordering but maybe it is best to be explicit.
readthedocs/projects/models.py
Outdated
@@ -845,6 +845,12 @@ def get_latest_build(self, finished=True): | |||
|
|||
:param finished: Return only builds that are in a finished state | |||
""" | |||
if hasattr(self, '_latest_build'): | |||
# Cached latest build |
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 think it could be useful to extend this comment indicating where this comes from (dashboard queryset), why it's needed or similar since the source it's in another file and I think we will not find this quickly when reading the code later.
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 agree. How about after #5472 is merged I'll refactor this slightly to have a class variable for caching it.
I refactored this optimization to be on the manager instead of sprinkled in a few functions. |
Seems like a better approach :) |
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.
💯
Note that I used the HTML5
<time>
tag to represent the datetime. This tag has attributes that have a machine readable datetime as well as a title with a precise locale-specific human-readable datetime as opposed to the nebulous "a year ago". I think we should use this convention or something like it more widely.This PR builds on some optimizations in #5472 and this should be refactored slightly if that is merged first.
Screenshot