summaryrefslogtreecommitdiffstats
path: root/models/repo_list.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2018-10-18 11:14:28 +0800
committertechknowlogick <hello@techknowlogick.com>2018-10-17 23:14:28 -0400
commit486e989a3979684ba428a129492881de12ec923a (patch)
treec3c1c992195be1c36f2726301aca8d408e52e4cf /models/repo_list.go
parente79e9248fd9d539ecc912fcc24e7a669ce98bdaf (diff)
downloadgitea-486e989a3979684ba428a129492881de12ec923a.tar.gz
gitea-486e989a3979684ba428a129492881de12ec923a.zip
feat(topic): search keyword by splitting provided values by , (#4939)
Diffstat (limited to 'models/repo_list.go')
-rw-r--r--models/repo_list.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/models/repo_list.go b/models/repo_list.go
index c7e292d8a9..4368057e04 100644
--- a/models/repo_list.go
+++ b/models/repo_list.go
@@ -205,11 +205,14 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err
if opts.Keyword != "" {
var keywordCond = builder.NewCond()
- if opts.TopicOnly {
- keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)})
- } else {
- keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(opts.Keyword)})
- keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)})
+ // separate keyword
+ for _, v := range strings.Split(opts.Keyword, ",") {
+ if opts.TopicOnly {
+ keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
+ } else {
+ keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(v)})
+ keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
+ }
}
cond = cond.And(keywordCond)
}