diff options
author | 6543 <m.huber@kithara.com> | 2024-03-16 11:32:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 10:32:45 +0000 |
commit | 1262ff6734543b37d834e63a6a623648c77ee4f4 (patch) | |
tree | cc99d1a96d094881a820659ea7fdf2d326b8a862 /modules/indexer/code/search.go | |
parent | e0ea3811c4178ffa30452b7ca4bd211e59326f91 (diff) | |
download | gitea-1262ff6734543b37d834e63a6a623648c77ee4f4.tar.gz gitea-1262ff6734543b37d834e63a6a623648c77ee4f4.zip |
Refactor code_indexer to use an SearchOptions struct for PerformSearch (#29724)
similar to how it's already done for the issue_indexer
---
*Sponsored by Kithara Software GmbH*
Diffstat (limited to 'modules/indexer/code/search.go')
-rw-r--r-- | modules/indexer/code/search.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/indexer/code/search.go b/modules/indexer/code/search.go index 89a62a8d3e..51c7595cf8 100644 --- a/modules/indexer/code/search.go +++ b/modules/indexer/code/search.go @@ -32,6 +32,8 @@ type ResultLine struct { type SearchResultLanguages = internal.SearchResultLanguages +type SearchOptions = internal.SearchOptions + func indices(content string, selectionStartIndex, selectionEndIndex int) (int, int) { startIndex := selectionStartIndex numLinesBefore := 0 @@ -125,12 +127,12 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Res // PerformSearch perform a search on a repository // if isFuzzy is true set the Damerau-Levenshtein distance from 0 to 2 -func PerformSearch(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isFuzzy bool) (int, []*Result, []*internal.SearchResultLanguages, error) { - if len(keyword) == 0 { +func PerformSearch(ctx context.Context, opts *SearchOptions) (int, []*Result, []*SearchResultLanguages, error) { + if opts == nil || len(opts.Keyword) == 0 { return 0, nil, nil, nil } - total, results, resultLanguages, err := (*globalIndexer.Load()).Search(ctx, repoIDs, language, keyword, page, pageSize, isFuzzy) + total, results, resultLanguages, err := (*globalIndexer.Load()).Search(ctx, opts) if err != nil { return 0, nil, nil, err } |