3
0

Fix issue with session list

It fixes issue of sorting and pagination for the status column due to Its stringify interpretation.
This commit is contained in:
Vivek Patel
2023-04-19 17:56:31 +05:30
committed by Jože Fortun
parent a0b128676b
commit 7fcfb40d2e
2 changed files with 13 additions and 5 deletions

View File

@@ -67,6 +67,14 @@ func (ctrl Session) List(ctx context.Context, r *request.SessionList) (interface
return nil, err
}
// fixes issue with sorting of status column and pagination
// need to improve on cursor for this
if f.Paging.PageCursor != nil {
for _, status := range r.Status {
f.Paging.PageCursor.Set("status", status, false)
}
}
f.IncTotal = r.IncTotal
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {

View File

@@ -252,7 +252,7 @@ func (p *PagingCursor) UnmarshalJSON(in []byte) error {
}
}
if err := json.Unmarshal(in, &aux); err != nil {
if err = json.Unmarshal(in, &aux); err != nil {
return err
}
@@ -287,10 +287,10 @@ func (p *PagingCursor) Decode(cursor string) error {
}
// Sort returns:
// - sort if cursor is nil
// - sort from cursor when sort is empty
// - sort from cursor when sort is compatible with cursor
// - error if sort & cursor are incompatible
// - sort if cursor is nil
// - sort from cursor when sort is empty
// - sort from cursor when sort is compatible with cursor
// - error if sort & cursor are incompatible
func (p *PagingCursor) Sort(sort SortExprSet) (SortExprSet, error) {
if p == nil {
return sort, nil