Skip to content

Commit 4ce042a

Browse files
rodolfoBeegetsantry[bot]cursoragentTkDodo
authored andcommitted
change query to check all repos, not only the first page. (#112334)
fixes #112332 This changes how repos are fetched so all repos are listed for code mappings. --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Dominik Dorfmeister 🔮 <dominik.dorfmeister@sentry.io>
1 parent 2e4a1e6 commit 4ce042a

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

static/app/views/settings/organizationIntegrations/integrationCodeMappings.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ import type {
2323
RepositoryProjectPathConfig,
2424
} from 'sentry/types/integrations';
2525
import {trackAnalytics} from 'sentry/utils/analytics';
26+
import {useFetchAllPages} from 'sentry/utils/api/apiFetch';
27+
import {apiOptions} from 'sentry/utils/api/apiOptions';
2628
import {getApiUrl} from 'sentry/utils/api/getApiUrl';
2729
import {getIntegrationIcon} from 'sentry/utils/integrationUtil';
2830
import {
2931
useApiQuery,
32+
useInfiniteQuery,
3033
useMutation,
3134
useQueryClient,
3235
type ApiQueryKey,
@@ -159,19 +162,31 @@ export function IntegrationCodeMappings({integration}: {integration: Integration
159162
{staleTime: 10_000}
160163
);
161164

165+
const repositoriesQuery = useInfiniteQuery({
166+
...apiOptions.asInfinite<Repository[]>()(
167+
'/organizations/$organizationIdOrSlug/repos/',
168+
{
169+
path: {organizationIdOrSlug: organization.slug},
170+
query: {status: 'active', per_page: 100},
171+
staleTime: 10_000,
172+
}
173+
),
174+
select: data => data.pages.flatMap(page => page.json),
175+
});
176+
useFetchAllPages({result: repositoriesQuery});
177+
162178
const {
163179
data: fetchedRepos = [],
164-
isPending: isPendingRepos,
180+
isPending: isPendingReposQuery,
165181
isError: isErrorRepos,
166-
} = useApiQuery<Repository[]>(
167-
[
168-
getApiUrl(`/organizations/$organizationIdOrSlug/repos/`, {
169-
path: {organizationIdOrSlug: organization.slug},
170-
}),
171-
{query: {status: 'active'}},
172-
],
173-
{staleTime: 10_000}
174-
);
182+
hasNextPage: hasNextReposPage,
183+
isFetchingNextPage: isFetchingNextReposPage,
184+
} = repositoriesQuery;
185+
186+
const isPendingRepos =
187+
isPendingReposQuery ||
188+
isFetchingNextReposPage ||
189+
(!!hasNextReposPage && !isErrorRepos);
175190

176191
const pathConfigs = useMemo(() => {
177192
return sortBy(fetchedPathConfigs, [

0 commit comments

Comments
 (0)