diff --git a/compose/rest/record.go b/compose/rest/record.go index 2b03ab4ae..5398ddb14 100644 --- a/compose/rest/record.go +++ b/compose/rest/record.go @@ -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 }