Skip to content

Dashboard: don't prefetch latest build #12400

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Dashboard: don't prefetch latest build #12400

wants to merge 6 commits into from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Aug 13, 2025

get_latest_build was doing something different than the prefetched value, looks like we never actually used this function with finished=True, so I went ahead and renamed it and made it a property so we can cache it.

@stsewd stsewd requested a review from a team as a code owner August 13, 2025 00:06
@stsewd stsewd requested a review from agjohnson August 13, 2025 00:06
@@ -1100,23 +1098,17 @@ def full_find(self, filename, version):
matches.append(os.path.join(root, match))
return matches

@lru_cache(maxsize=1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also reduce the number of queries on .com, nothing like an old fashioned caching.

@stsewd stsewd marked this pull request as draft August 13, 2025 00:09
@stsewd stsewd marked this pull request as ready for review August 13, 2025 22:30
@stsewd
Copy link
Member Author

stsewd commented Aug 13, 2025

Tests for the number of queries should pass after readthedocs/ext-theme#639 is merged

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments about a small change in behavior, but looks good otherwise.

@@ -399,7 +399,7 @@ def test_dashboard_number_of_queries(self):
state=BUILD_STATE_FINISHED,
)

with self.assertNumQueries(12):
with self.assertNumQueries(27):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want a note here explaining that more small fast queries here are better than a few slow ones.

@@ -30,7 +30,7 @@ def get_context_data(self, **kwargs):

# Show for the first few builds, return last build state
if project.builds.count() <= 5:
onboard["build"] = project.get_latest_build(finished=False)
onboard["build"] = project.latest_internal_build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there is some change in behavior here. We were returning unfinished builds before, and now we are returning anyone. Is that expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants