Mentorship-backend: Allow pagination of /users endpoint

Created on 15 Dec 2019  路  12Comments  路  Source: anitab-org/mentorship-backend

Is your feature request related to a problem? Please describe.
Currently, the only way to get a list of users is to GET /users. There's one problem with this approach: as there will be more and more users, the size of the data returned will proportionally grow.
As of now it isn't a problem, but imagine what happens when we have 5000 users?

Describe the solution you'd like
I'd like to have pagination support in GET /users endpoint. Instead of returning all users at once, it'd return, say, 50 and upon a next request, another 50.
I've never done pagination before so I don't exactly know how this could be implemented,but I think the effort put will be worth it. Maintaining scalability is really important.

Describe alternatives you've considered
I'm not aware of other alternatives.

Coding Enhancement

Most helpful comment

Sure @brianguo98 and @lmcicat. I will assign this to you

All 12 comments

That is a great idea that I have not thought of before :) thank you for creating this feature request @bartekpacia 馃帀Even fi you don't have a solution proposed, its great that you proposed a new idea for the future development of the app! 馃檶

This is something that could be totally thought of and for other apis as well. This also, reminds me of having a search feature (no issue created for that as well).

Also eventually the mentorship-relation API could use some pagination as well 馃槈

Thanks for response. The task seems quite hard, I think it requires kind of in-depth knowledge of the inner workings of the whole system. Anyway, I'll poke around with it in the future

BTW it looks like this a few issues can be made of this one (one issue for every "module" of the app e.g users, tasks).

Okay, I've been tinkering with it for a while and it turned out to be really simple! Flask and SQLAlchemy is an incredibly powerful combo馃敟

This issue is available for any contributor. This feature was almost completed with PR #294
If you want to continue this work feel free to use this solution or propose other. As you wish!
But before sending a PR, please let us know you want to work on this, so we can assign this to you.

Hi @isabelcosta, @lmcicat and I are happy to pick up the work here, we have a couple of ideas and would like to get started while we wait for our other PR to be reviewed. Thank you :)

Sure @brianguo98 and @lmcicat. I will assign this to you

Hey @isabelcosta . we have locally implemented pagination for /users. would you like this issue / PR also include pagination for /users/verified?

Also, how many users do you want to be in each page? We have it set to 10 right now, but want to know if you had another value in mind.

Hey @isabelcosta . we have locally implemented pagination for /users. would you like this issue / PR also include pagination for /users/verified?

Hum, we intend to deprecate /users/verified, but until we do, if you could do this for that endpoint as well, that would be great. The android client uses GET /users/verified

Also, how many users do you want to be in each page? We have it set to 10 right now, but want to know if you had another value in mind.

@lmcicat I have no idea as of now 馃 10 sounds good :)

@isabelcosta PR is up at #541. Thanks!

@robotjellyzone gave me a great idea! 馃帀 To document why this is needed!

Here's the current problem that can be solved by this pagination feature:
image

Heroku logs:

image

So basically, sometimes it takes too much time to query all the users, right?

So basically, sometimes it takes too much time to query all the users, right?

yep

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isabelcosta picture isabelcosta  路  22Comments

isabelcosta picture isabelcosta  路  25Comments

paritoshsinghrahar picture paritoshsinghrahar  路  25Comments

isabelcosta picture isabelcosta  路  47Comments

PrashanthPuneriya picture PrashanthPuneriya  路  22Comments