mlemesle / rustemon

A wrapper library for PokeApi, written in Rust
MIT License
27 stars 10 forks source link

Improve `get_all_pages` #17

Closed ChaseParate closed 1 year ago

ChaseParate commented 1 year ago

Right now, the get_all_pages endpoint function is very slow. It uses the get_page function, which defaults to retrieving only 20 entries at once. Thus, when trying to fetch all entries from a resource with many entries (such as rustemon::pokemon::pokemon_species, which contains over a thousand entries), many extraneous requests are sent, which greatly impacts performance. This can be fixed by lowering the number of requests and asking for the proper amount of entries within the requests.

I also updated one of the examples, which displays the increased performance.

mlemesle commented 1 year ago

Hey there,

Sorry for the delay ! Nice catch, I'll look into it !

mlemesle commented 1 year ago

Nice job there, thanks for your contribution ! Just one minor change, tell me if you want me to handle it.

ChaseParate commented 1 year ago

Got it!