1
0

fix: order by clause in task comments

This commit is contained in:
kolaente
2023-08-31 15:44:59 +02:00
parent 5392ca788c
commit 5811d2a13b
2 changed files with 12 additions and 8 deletions

View File

@ -238,13 +238,17 @@ func (tc *TaskComment) ReadAll(s *xorm.Session, auth web.Auth, search string, pa
limit, start := getLimitFromPageIndex(page, perPage)
comments := []*TaskComment{}
where := []builder.Cond{
builder.Eq{"task_id": tc.TaskID},
}
if search != "" {
where = append(where, db.ILIKE("comment", search))
}
query := s.
Where(builder.And(
builder.Eq{"task_id": tc.TaskID},
db.ILIKE("comment", search),
)).
Where(builder.And(where...)).
Join("LEFT", "users", "users.id = task_comments.author_id").
OrderBy("id", "asc")
OrderBy("task_comments.id asc")
if limit > 0 {
query = query.Limit(limit, start)
}