#2417 Add pagination to the projects API
Merged by pingou. Opened by mprahl.
Unknown source master

Download 2417.patch

Since there is such a large amount of repos in pagure-over-dist-git, the projects API times out after about 8 minutes. This PR adds pagination so that we can workaround this limitation.

@pingou, I made the API backwards compatible, meaning there are no differences in the API unless you specify the page argument. I chose this route over an API version bump since it's a much smaller undertaking. Please let me know your thoughts on this.

I think we should define a max there as well, otherwise it gets too easy to DDOS the server by asking for too much info.

I've had the tendency to use a count=False and limit=None, offset=None in other projects, but that's one way to do it.

The reason I did this is that I wanted the total count before doing limit and offset. It saves a query.

rebased

@pingou I addressed your comments. Please let me know if you need anything else done.

The reason I did this is that I wanted the total count before doing limit and offset. It saves a query.

You do two queries regardless no? One for the data, one for the count, and what I was describing would have worked just fine this way as well (just call the function with count=True first).
But I don't see how the ordering the calls change something, do I miss something?

rebased

@pingou you're right. I addressed your comment. Please review again.

Looking good, do you want to do the rebase or shall I?

rebased

@pingou I just rebased it. In the future, you can do this :smile:

Pull-Request has been merged by pingou

Metadata