mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-04 02:12:30 +02:00
Merge pull request 'feat: Add Search to Releases Page' (#5777) from JakobDev/forgejo:releasesearch into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5777 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
This commit is contained in:
commit
d5426b0626
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