mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 04:55:18 +00:00
return maxPerPage (not defaultPerPage) if per_page is greater than max (#3124)
it's more user-friendly. Refs #3065
This commit is contained in:
committed by
Ethan Buchman
parent
bc00a032c1
commit
4daca1a634
@@ -21,6 +21,7 @@ Special thanks to external contributors on this release:
|
||||
### FEATURES:
|
||||
|
||||
### IMPROVEMENTS:
|
||||
- [rpc] \#3065 return maxPerPage (100), not defaultPerPage (30) if `per_page` is greater than the max 100.
|
||||
|
||||
### BUG FIXES:
|
||||
- [log] \#3060 fix year format
|
||||
|
||||
@@ -149,8 +149,10 @@ func validatePage(page, perPage, totalCount int) int {
|
||||
}
|
||||
|
||||
func validatePerPage(perPage int) int {
|
||||
if perPage < 1 || perPage > maxPerPage {
|
||||
if perPage < 1 {
|
||||
return defaultPerPage
|
||||
} else if perPage > maxPerPage {
|
||||
return maxPerPage
|
||||
}
|
||||
return perPage
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ func TestPaginationPage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPaginationPerPage(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
totalCount int
|
||||
perPage int
|
||||
@@ -59,7 +58,7 @@ func TestPaginationPerPage(t *testing.T) {
|
||||
{5, defaultPerPage, defaultPerPage},
|
||||
{5, maxPerPage - 1, maxPerPage - 1},
|
||||
{5, maxPerPage, maxPerPage},
|
||||
{5, maxPerPage + 1, defaultPerPage},
|
||||
{5, maxPerPage + 1, maxPerPage},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
||||
Reference in New Issue
Block a user