Skip to content

Commit

Permalink
Extract MAX_RANKED_RESULTS
Browse files Browse the repository at this point in the history
  • Loading branch information
gzdunek authored and github-actions committed May 10, 2024
1 parent c2e6b88 commit 28dd7d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web/packages/teleterm/src/ui/Search/useSearch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('useResourceSearch', () => {
clusterUri: cluster.uri,
search: '',
filters: [],
limit: 20,
limit: 10,
});
expect(appContext.resourcesService.searchResources).toHaveBeenCalledTimes(
1
Expand Down
5 changes: 3 additions & 2 deletions web/packages/teleterm/src/ui/Search/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type CrossClusterResourceSearchResult = {
search: string;
};

const MAX_RANKED_RESULTS = 10;
const SUPPORTED_RESOURCE_TYPES: ResourceTypeFilter[] = [
'node',
'app',
Expand Down Expand Up @@ -90,7 +91,7 @@ export function useResourceSearch() {
// In preview mode we know that the user didn't specify any search terms. So instead of
// fetching all 100 resources, we fetch only a bunch of them to show
// example results in the UI.
limit = 20;
limit = MAX_RANKED_RESULTS;
break;
}
case 'full-search': {
Expand Down Expand Up @@ -262,7 +263,7 @@ export function rankResults(
b.score - a.score ||
collator.compare(mainResourceName(a), mainResourceName(b))
)
.slice(0, 10);
.slice(0, MAX_RANKED_RESULTS);
}

function populateMatches(
Expand Down

0 comments on commit 28dd7d5

Please sign in to comment.