Skip to content

Commit

Permalink
Change repo search to use exact match for topic search. (#7941)
Browse files Browse the repository at this point in the history
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
  • Loading branch information
davidsvantesson authored and techknowlogick committed Aug 23, 2019
1 parent 4ea9a37 commit ca6fb00
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion models/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err
// separate keyword
var subQueryCond = builder.NewCond()
for _, v := range strings.Split(opts.Keyword, ",") {
subQueryCond = subQueryCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
if opts.TopicOnly {
subQueryCond = subQueryCond.Or(builder.Eq{"topic.name": strings.ToLower(v)})
} else {
subQueryCond = subQueryCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
}
}
subQuery := builder.Select("repo_topic.repo_id").From("repo_topic").
Join("INNER", "topic", "topic.id = repo_topic.topic_id").
Expand Down

0 comments on commit ca6fb00

Please sign in to comment.