Skip to content

Commit 70b4e5a

Browse files
authored
GitHub App: faster migration page (#12186)
For some things, we are returning lists of objects, so no lazy iteration is possible for those. So I'm loading those only when the proper step needs them.
1 parent 99ec640 commit 70b4e5a

File tree

3 files changed

+247
-76
lines changed

3 files changed

+247
-76
lines changed

readthedocs/oauth/migrate.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _get_github_account_target(remote_repository) -> GitHubAccountTarget | None:
214214

215215
def _get_projects_missing_migration(user) -> Iterator[tuple[Project, bool, bool]]:
216216
"""
217-
Get all projects where the user has admin permissions that are still connected to the old GitHub OAuth App.
217+
Get all projects where the user has access that are still connected to the old GitHub OAuth App.
218218
219219
Returns an iterator with the project, a boolean indicating if the GitHub App is installed on the repository,
220220
and a boolean indicating if the user has admin permissions on the repository.
@@ -261,7 +261,7 @@ def get_migrated_projects(user):
261261
)
262262

263263

264-
def get_valid_projects_missing_migration(user):
264+
def get_valid_projects_missing_migration(user) -> Iterator[Project]:
265265
"""
266266
Get all projects that the user can migrate to the GitHub App.
267267
@@ -296,6 +296,16 @@ def get_migration_targets(user) -> list[MigrationTarget]:
296296
return targets
297297

298298

299+
def has_projects_pending_migration(user) -> bool:
300+
"""
301+
Check if the user has any projects pending migration to the GitHub App.
302+
303+
This includes all projects that are connected to the old GitHub OAuth App,
304+
where the user has admin permissions and the GitHub App is installed.
305+
"""
306+
return any(_get_projects_missing_migration(user))
307+
308+
299309
def get_old_app_link() -> str:
300310
"""
301311
Get the link to the old GitHub OAuth App settings page.

0 commit comments

Comments
 (0)