feat: Add Search to Releases Page

This commit is contained in:
JakobDev 2024-11-02 10:24:35 +01:00
parent e5e2860221
commit 86546fe63e
No known key found for this signature in database
GPG key ID: 39DEF62C3ED6DC4C
7 changed files with 69 additions and 3 deletions

View file

@ -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
}