@@ -49,32 +49,29 @@ func (i *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
49
49
// But the two functions are used in modules/notification/indexer, that means we will import services/indexer in modules/notification/indexer.
50
50
// So that's the root problem:
51
51
// The notification is defined in modules, but it's using lots of things should be in services.
52
-
53
52
cond := builder .NewCond ()
54
53
if options .Keyword != "" {
55
54
repoCond := builder .In ("repo_id" , options .RepoIDs )
56
55
if len (options .RepoIDs ) == 1 {
57
56
repoCond = builder.Eq {"repo_id" : options .RepoIDs [0 ]}
58
57
}
59
58
60
- if options .Index .Has () {
61
- cond = builder .And (
59
+ subQuery := builder .Select ("id" ).From ("issue" ).Where (repoCond )
60
+ cond = builder .Or (
61
+ db .BuildCaseInsensitiveLike ("issue.name" , options .Keyword ),
62
+ db .BuildCaseInsensitiveLike ("issue.content" , options .Keyword ),
63
+ builder .In ("issue.id" , builder .Select ("issue_id" ).
64
+ From ("comment" ).
65
+ Where (builder .And (
66
+ builder.Eq {"type" : issue_model .CommentTypeComment },
67
+ builder .In ("issue_id" , subQuery ),
68
+ db .BuildCaseInsensitiveLike ("content" , options .Keyword ),
69
+ )),
70
+ ),
71
+ )
72
+ if options .IsKeywordNumeric () {
73
+ cond = cond .Or (
62
74
builder.Eq {"`index`" : options .Keyword },
63
- repoCond ,
64
- )
65
- } else {
66
- subQuery := builder .Select ("id" ).From ("issue" ).Where (repoCond )
67
- cond = builder .Or (
68
- db .BuildCaseInsensitiveLike ("issue.name" , options .Keyword ),
69
- db .BuildCaseInsensitiveLike ("issue.content" , options .Keyword ),
70
- builder .In ("issue.id" , builder .Select ("issue_id" ).
71
- From ("comment" ).
72
- Where (builder .And (
73
- builder.Eq {"type" : issue_model .CommentTypeComment },
74
- builder .In ("issue_id" , subQuery ),
75
- db .BuildCaseInsensitiveLike ("content" , options .Keyword ),
76
- )),
77
- ),
78
75
)
79
76
}
80
77
}
0 commit comments