Skip to content

Commit 3bf81a4

Browse files
committed
fix(github): Only use cache when search query is present
Avoid caching the initial no-query load when accessibleOnly is set. Cache is only useful for debounced keystroke searches, not the first page load which should always return fresh data.
1 parent 155c015 commit 3bf81a4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/sentry/integrations/api/endpoints/organization_integration_repos.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def get(
7272

7373
try:
7474
repositories = install.get_repositories(
75-
search, accessible_only=accessible_only, use_cache=accessible_only
75+
search,
76+
accessible_only=accessible_only,
77+
use_cache=accessible_only and bool(search),
7678
)
7779
except (IntegrationError, IdentityNotValid) as e:
7880
return self.respond({"detail": str(e)}, status=400)

tests/sentry/integrations/api/endpoints/test_organization_integration_repos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_accessible_only_without_search(self, get_repositories: MagicMock) -> No
224224
response = self.client.get(self.path, format="json", data={"accessibleOnly": "true"})
225225

226226
assert response.status_code == 200, response.content
227-
get_repositories.assert_called_once_with(None, accessible_only=True, use_cache=True)
227+
get_repositories.assert_called_once_with(None, accessible_only=True, use_cache=False)
228228

229229
@patch(
230230
"sentry.integrations.github.integration.GitHubIntegration.get_repositories", return_value=[]

0 commit comments

Comments
 (0)