Skip to content

Commit f3b9dd4

Browse files
committed
fix search issue with ids
1 parent 61e2015 commit f3b9dd4

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

modules/indexer/issues/db/db.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ func (i *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
121121
}, nil
122122
}
123123

124-
ids, total, err := issue_model.IssueIDs(ctx, opt, cond)
124+
return i.FindWithIssueOptions(ctx, opt, cond)
125+
}
126+
127+
func (i *Indexer) FindWithIssueOptions(ctx context.Context, opt *issue_model.IssuesOptions, otherConds ...builder.Cond) (*internal.SearchResult, error) {
128+
ids, total, err := issue_model.IssueIDs(ctx, opt, otherConds...)
125129
if err != nil {
126130
return nil, err
127131
}

routers/web/repo/issue_list.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package repo
55

66
import (
77
"bytes"
8-
"fmt"
98
"maps"
109
"net/http"
1110
"slices"
@@ -34,14 +33,6 @@ import (
3433
pull_service "code.gitea.io/gitea/services/pull"
3534
)
3635

37-
func issueIDsFromSearch(ctx *context.Context, keyword string, opts *issues_model.IssuesOptions) ([]int64, error) {
38-
ids, _, err := issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, opts))
39-
if err != nil {
40-
return nil, fmt.Errorf("SearchIssues: %w", err)
41-
}
42-
return ids, nil
43-
}
44-
4536
func retrieveProjectsForIssueList(ctx *context.Context, repo *repo_model.Repository) {
4637
ctx.Data["OpenProjects"], ctx.Data["ClosedProjects"] = retrieveProjectsInternal(ctx, repo)
4738
}
@@ -561,7 +552,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID, projectID int6
561552
IssueIDs: nil,
562553
}
563554
if keyword != "" {
564-
keywordMatchedIssueIDs, err = issueIDsFromSearch(ctx, keyword, statsOpts)
555+
keywordMatchedIssueIDs, _, err = issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, statsOpts))
565556
if err != nil {
566557
if issue_indexer.IsAvailable(ctx) {
567558
ctx.ServerError("issueIDsFromSearch", err)
@@ -626,7 +617,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID, projectID int6
626617
// Either it did search with the keyword, and found some issues, then keywordMatchedIssueIDs is not null, it needs to use db indexer.
627618
// Or the keyword is empty, it also needs to usd db indexer.
628619
// In either case, no need to use keyword anymore
629-
searchResult, err := db_indexer.GetIndexer().Search(ctx, issue_indexer.ToSearchOptions("", &issues_model.IssuesOptions{
620+
searchResult, err := db_indexer.GetIndexer().FindWithIssueOptions(ctx, &issues_model.IssuesOptions{
630621
Paginator: &db.ListOptions{
631622
Page: pager.Paginater.Current(),
632623
PageSize: setting.UI.IssuePagingNum,
@@ -644,7 +635,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID, projectID int6
644635
LabelIDs: preparedLabelFilter.SelectedLabelIDs,
645636
SortType: sortType,
646637
IssueIDs: keywordMatchedIssueIDs,
647-
}))
638+
})
648639
if err != nil {
649640
ctx.ServerError("DBIndexer.Search", err)
650641
return

0 commit comments

Comments
 (0)