Skip to content
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

adding pagination support to the Consumers resource #63

Merged
merged 7 commits into from
Jan 3, 2017

Conversation

ErwannRobin
Copy link
Contributor

Useful when you have more than 100 consumers on Kong

@PGBI
Copy link
Owner

PGBI commented Dec 27, 2016

Ah, I'm surprised this didn't come up sooner. Looks like you're the only one with more than 100 consumers! Thanks for this PR.

Would you mind completing it to also handle pagination for APIs and Plugins resources?

@ErwannRobin
Copy link
Contributor Author

@PGBI : done for the APIs and Plugins resources, but not yet for '/apis/:api_id/plugins' and '/consumers/:consumer_id/plugins' because it seems more tricky.

@PGBI
Copy link
Owner

PGBI commented Dec 28, 2016

@diwann So I checked out the code to test it locally, and found these issues:

  • being on http://localhost:8080/#/consumers, with around 4000 consumers, when I click "Go to next Page", I'm redirected to http://localhost:8080/#/consumers?offset=undefined&size=, which doesn't load the next page. I'm using Chrome.
  • The shortcut "Check the Plugins for this Consumer" on the consumer edit form is a good idea. However, it's also displayed on the consumer creation form (http://localhost:8080/#/consumers/add) which doesn't make sense in that context.
  • I don't understand the "Gelato Links for consumers" on the config page. What is that?

Regarding '/apis/:api_id/plugins' and '/consumers/:consumer_id/plugins', if paginating them is tricky, I guess we can leave them for now. Being able to paginate consumers, apis and plugins will already be a great improvement!

@ErwannRobin
Copy link
Contributor Author

ErwannRobin commented Dec 29, 2016

  1. What do you get on: http://localhost:8001/consumers ?
    Does it work on: http://localhost:8080/#/apis?size=1 ?
  2. Fixed
  3. This will conditionally create shortcuts links to the profile page of the same consumer on the gelato dashboard (like https://gelato.io/app/developers/582187067111376096). Because I am constantly switching to it and copy-pasting the consumer id is not ideal
    cf:
    image

@PGBI
Copy link
Owner

PGBI commented Dec 30, 2016

When I browse http://localhost:8080/#/consumers I get this:

capture d ecran 2016-12-30 a 14 56 09

Then, when clicking on "Go To next page", the browser location is set to http://localhost:8080/#/consumers?offset=undefined&size= and I'm still seing page 1.

@ErwannRobin
Copy link
Contributor Author

no, I really meant on "http://localhost:8001/consumers", assuming your Kong node is on localhost?

on my side, I have:
image

@PGBI
Copy link
Owner

PGBI commented Dec 30, 2016

My bad, didn't read properly your question. I'm getting this:

{
  "next": "http://localhost:8001/consumers?size=100&offset=ABAjkv8D155L5LLViAu8HE4OAAsACHVzZXJuYW1lAH%2F%2F%2F5s%3D",
  "data": [
    {
      "custom_id": "3130",
      "username": "App-3130",
      "created_at": 1469234887000,
      "id": "a0754d16-6108-4e8a-9688-5151d6647062"
    },
    { 
      ...
    }
]

This is with Kong 0.6.1

@ErwannRobin
Copy link
Contributor Author

ErwannRobin commented Jan 2, 2017

Ok, fixed. it seems that Kong 0.6.1 didn't had the "offset" parameter.
Also, I finally tackled the pagination of '/apis/:api_id/plugins' and '/consumers/:consumer_id/plugins'

and Happy New Year!

@PGBI
Copy link
Owner

PGBI commented Jan 3, 2017

@diwann Parfait, c'est mergé. Merci pour ta contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants