Skip to content

Commit c885645

Browse files
authored
GitHub App: small queryset improvements (#12446)
1 parent 9eb0868 commit c885645

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

readthedocs/oauth/services/githubapp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def sync_user_access(cls, user):
159159
queryset = RemoteRepository.objects.filter(
160160
remote_repository_relations__user=user,
161161
vcs_provider=cls.vcs_provider_slug,
162-
)
162+
).select_related("github_app_installation")
163163
# Group by github_app_installation, so we don't create multiple clients.
164164
grouped_installations = groupby(
165165
queryset,
@@ -177,7 +177,9 @@ def sync_user_access(cls, user):
177177
vcs_provider=cls.vcs_provider_slug,
178178
)
179179
for remote_organization in queryset:
180-
remote_repo = remote_organization.repositories.first()
180+
remote_repo = remote_organization.repositories.select_related(
181+
"github_app_installation"
182+
).first()
181183
# NOTE: this should never happen, unless our data is out of sync
182184
# (we delete orphaned organizations when deleting projects).
183185
if not remote_repo:

0 commit comments

Comments
 (0)