Skip to content

Commit 155c015

Browse files
committed
ref(github): Rename get_accessible_repos_cached to get_repos_cached
Rename method and cache key to reflect that the cache is not specific to the accessible_only path. Remove implementation-detail comments from get_repositories.
1 parent 68df5e6 commit 155c015

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/sentry/integrations/github/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,16 +558,15 @@ def get_repos(self, page_number_limit: int | None = None) -> list[dict[str, Any]
558558
page_number_limit=page_number_limit,
559559
)
560560

561-
def get_accessible_repos_cached(self, ttl: int = 300) -> list[CachedRepo]:
561+
def get_repos_cached(self, ttl: int = 300) -> list[CachedRepo]:
562562
"""
563-
Return all repos accessible to this installation.
564-
Cached in Django cache for ``ttl`` seconds so that debounced
565-
search keystrokes don't re-fetch all pages from GitHub.
563+
Return all repos accessible to this installation, cached in
564+
Django cache for ``ttl`` seconds.
566565
567566
Only the fields used by get_repositories() are stored to keep
568567
the cache payload small.
569568
"""
570-
cache_key = f"github:accessible_repos:{self.integration.id}"
569+
cache_key = f"github:repos:{self.integration.id}"
571570
cached = cache.get(cache_key)
572571
if cached is not None:
573572
return cached

src/sentry/integrations/github/integration.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,13 @@ def to_repo_info(raw_repos: Iterable[Mapping[str, Any]]) -> list[RepositoryInfo]
354354

355355
def _get_all_repos():
356356
if use_cache:
357-
return client.get_accessible_repos_cached()
357+
return client.get_repos_cached()
358358
return client.get_repos(page_number_limit=page_number_limit)
359359

360-
# No query: return all non-archived repos
361360
if not query:
362361
all_repos = _get_all_repos()
363362
return to_repo_info(r for r in all_repos if not r.get("archived"))
364363

365-
# accessible_only: fetch accessible repos and filter locally
366-
# avoids the Search API's 30 req/min shared rate limit
367364
if accessible_only:
368365
all_repos = _get_all_repos()
369366
query_lower = query.lower()
@@ -373,7 +370,6 @@ def _get_all_repos():
373370
if not r.get("archived") and query_lower in r["full_name"].lower()
374371
)
375372

376-
# Query without accessible_only: use the Search API
377373
assert not use_cache, "use_cache is not supported with the Search API path"
378374
full_query = build_repository_query(self.model.metadata, self.model.name, query)
379375
response = client.search_repositories(full_query)

0 commit comments

Comments
 (0)