chore: refactor searching for link shares

This commit is contained in:
kolaente 2025-06-18 09:45:11 +02:00
parent 3db1ddcee4
commit a571d42f46
2 changed files with 9 additions and 8 deletions

View File

@ -24,6 +24,7 @@
updated: 2018-12-02 15:13:12
- id: 4
hash: testWithPassword
name: testWithPassword
project_id: 1
right: 0
password: '$2a$04$X4aRMEt0ytgPwMIgv36cI..7X9.nhY/.tYwxpqSi0ykRHx2CwQ0S6' # 12345678

View File

@ -220,14 +220,14 @@ func (share *LinkSharing) ReadAll(s *xorm.Session, a web.Auth, search string, pa
limit, start := getLimitFromPageIndex(page, perPage)
var shares []*LinkSharing
query := s.
Where(builder.And(
builder.Eq{"project_id": share.ProjectID},
builder.Or(
db.ILIKE("hash", search),
db.ILIKE("name", search),
),
))
var where []builder.Cond
where = append(where, builder.Eq{"project_id": share.ProjectID})
if search != "" {
where = append(where, db.ILIKE("name", search))
}
query := s.Where(builder.And(where...))
if limit > 0 {
query = query.Limit(limit, start)