forked from vikunja/vikunja
orderBy in task_comments.go
This commit is contained in:
parent
d1799ff980
commit
74f7b5bdba
@ -18,6 +18,7 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
"fmt"
|
||||
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
|
||||
@ -37,6 +38,9 @@ type TaskComment struct {
|
||||
Author *user.User `xorm:"-" json:"author"`
|
||||
TaskID int64 `xorm:"not null" json:"-" param:"task"`
|
||||
|
||||
// The query parameter to order the items by. This can be either asc or desc, with asc being the default.
|
||||
OrderBy []string `query:"order_by" json:"order_by"`
|
||||
|
||||
Reactions ReactionMap `xorm:"-" json:"reactions"`
|
||||
|
||||
Created time.Time `xorm:"created" json:"created"`
|
||||
@ -270,7 +274,7 @@ func (tc *TaskComment) ReadAll(s *xorm.Session, auth web.Auth, search string, pa
|
||||
query := s.
|
||||
Where(builder.And(where...)).
|
||||
Join("LEFT", "users", "users.id = task_comments.author_id").
|
||||
OrderBy("task_comments.created asc")
|
||||
OrderBy(fmt.Sprintf("task_comments.created %s", tc.OrderBy[0]))
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user