Limit/default compose record list rest endpoint
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -60,6 +61,11 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
defaultRecordSearchSize uint = 500
|
||||
maxRecordSearchSize = 1000
|
||||
)
|
||||
|
||||
func (Record) New() *Record {
|
||||
return &Record{
|
||||
importSession: service.DefaultImportSession,
|
||||
@@ -101,6 +107,12 @@ func (ctrl *Record) List(ctx context.Context, r *request.RecordList) (interface{
|
||||
f.Query = r.Query
|
||||
}
|
||||
|
||||
if r.Limit == 0 {
|
||||
r.Limit = defaultRecordSearchSize
|
||||
}
|
||||
|
||||
r.Limit = uint(math.Min(float64(r.Limit), float64(maxRecordSearchSize)))
|
||||
|
||||
if f.Paging, err = filter.NewPaging(r.Limit, r.PageCursor); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user