-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination system to http endpoint executions/list #1689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this is only solution until next sprint.
x/execution/client/rest/query.go
Outdated
if start < 0 || end < 0 { | ||
execs = make([]*execution.Execution, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should return error if the pagination boundaries are invalid (so in that case check if page/limit <= 0), otherwise returning empty list.
s/execs = make([]*execution.Execution, 0)/execs = nil/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the page and limit <= 0 error is managed by rest.ParseHTTPArgs(r)
:
} else if page <= 0 {
return tags, page, limit, errors.New("page must greater than 0")
}
} else if limit <= 0 {
return tags, page, limit, errors.New("limit must greater than 0")
}
the problem with returning execs = nil
is it's not a list anymore in the json response:
{"height":"757","result":null}
so we will have issue with clients.
i would keep it as it is:
{"height":"773","result":[]}
i replaced the make([]*execution.Execution, 0)
by simply []*execution.Execution{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for one suggestion, lgtm
@krhubert @antho1404 modif done. please check again |
Added a simple and not optimized pagination system on
executions/list
HTTP endpoint so the explorer can fetch executions without breaking.The parameters
page
,limit
andsort=reverse
can be passed to the endpoint to return different executions:The sort is based on the execution's blockHeight
Related to #1679
Improvements that can be done now or later:
KVStorePrefixIteratorPaginated
but need to pass as parameters page, limit and find a way to sort the data without iterate on all of them (index?)