Skip to content

Commit f40f03e

Browse files
committed
fix(pagination): use the proper limit pagination style from DRF
Moved us to using limit instead of page_size so we didn't have to subclass things http://www.django-rest-framework.org/api-guide/pagination/#limitoffsetpagination Fixes #463
1 parent 0efdcaf commit f40f03e

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

client/controller/client/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c Client) Request(method string, path string, body []byte) (*http.Response
6969

7070
// LimitedRequest allows limiting the number of responses in a request.
7171
func (c Client) LimitedRequest(path string, results int) (string, int, error) {
72-
body, err := c.BasicRequest("GET", path+"?page_size="+strconv.Itoa(results), nil)
72+
body, err := c.BasicRequest("GET", path+"?limit="+strconv.Itoa(results), nil)
7373

7474
if err != nil {
7575
return "", -1, err

client/controller/client/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
4747
return
4848
}
4949

50-
if req.URL.Path == "/limited/" && req.Method == "GET" && req.URL.RawQuery == "page_size=2" {
50+
if req.URL.Path == "/limited/" && req.Method == "GET" && req.URL.RawQuery == "limit=2" {
5151
res.Write([]byte(limitedFixture))
5252
return
5353
}

rootfs/deis/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
'DEFAULT_RENDERER_CLASSES': (
160160
'rest_framework.renderers.JSONRenderer',
161161
),
162-
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
162+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
163163
'PAGE_SIZE': 100,
164164
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
165165
}

0 commit comments

Comments
 (0)