forked from kevadesu/forgejo
feat: Add Search to Releases Page
This commit is contained in:
parent
e5e2860221
commit
86546fe63e
7 changed files with 69 additions and 3 deletions
|
@ -249,6 +249,7 @@ type FindReleasesOptions struct {
|
|||
IsDraft optional.Option[bool]
|
||||
TagNames []string
|
||||
HasSha1 optional.Option[bool] // useful to find draft releases which are created with existing tags
|
||||
Keyword string
|
||||
}
|
||||
|
||||
func (opts FindReleasesOptions) ToConds() builder.Cond {
|
||||
|
@ -276,6 +277,15 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
|
|||
cond = cond.And(builder.Eq{"sha1": ""})
|
||||
}
|
||||
}
|
||||
|
||||
if opts.Keyword != "" {
|
||||
keywordCond := builder.NewCond()
|
||||
keywordCond = keywordCond.Or(builder.Like{"lower_tag_name", strings.ToLower(opts.Keyword)})
|
||||
keywordCond = keywordCond.Or(db.BuildCaseInsensitiveLike("title", opts.Keyword))
|
||||
keywordCond = keywordCond.Or(db.BuildCaseInsensitiveLike("note", opts.Keyword))
|
||||
cond = cond.And(keywordCond)
|
||||
}
|
||||
|
||||
return cond
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue