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

Remove all unbounded API calls from frontend #520

Open
4 tasks
batpad opened this issue Oct 27, 2022 · 2 comments
Open
4 tasks

Remove all unbounded API calls from frontend #520

batpad opened this issue Oct 27, 2022 · 2 comments
Assignees

Comments

@batpad
Copy link
Contributor

batpad commented Oct 27, 2022

There are still a few places on the frontend where we make unbounded API calls (i.e. where we set the limit parameter to the API to a really high number to ensure we fetch "all" results") instead of paginating through API responses and fetching a sane amount, say 100, elements at a time.

This is a blocker to us removing support for high limit values on the API - ideally, we would lock-down the API to not allow more than, say, 200 items in a single request.

We need to:

  • Identify all places in the frontend code where we make unbounded calls
  • Look for ways to change the logic to not need an unbounded call
  • For cases where we do need to fetch "all" items, implement request pagination on the frontend, similar to how we are handling CSV downloads on the frontend now.
  • Once the above is done, give warning to all API users, and then implement a limit restriction on the API.

I can start enumerating places where we are making unbounded calls on the frontend.

cc @frozenhelium @tovari @szabozoltan69

@batpad
Copy link
Contributor Author

batpad commented Oct 27, 2022

Starting to enumerate, we can create separate tickets for these if needed:

Looking through, we actually have a LOT of instances where we make calls with a high limit value. I think for MOST of them, we just want to switch to doing pagination on the frontend. For MOST cases, it's really harmless - we need to display everything on a map, or in a dropdown, we know there will likely not be many results, but don't want to cap it, so we set a high limit -- just setting pagination with a page size of 100 or 200 on the frontend should be fine for these.

There's cases like the call for "Active Personnel": https://github.com/IFRCGo/go-frontend/blob/develop/src/root/actions/index.js#L576 that need to fetch all items to display in a single chart - all these cases I think we should just handle in the same way we did CSV pagination.

I think then the only one that I'm really concerned about is the fetching of Appeals like https://github.com/IFRCGo/go-frontend/blob/develop/src/root/actions/index.js#L232 - I can't see a good reason why we need to fetch ALL appeals from the backend. We need to dig more into that and see if we can swap out the logic there, perhaps by doing some aggregation on the backend. For the rest, I would advocate finding a good pattern to just moving all these instances to doing pagination managed by the frontend.

Also, @frozenhelium, could you just comment on https://github.com/IFRCGo/go-frontend/blob/develop/src/root/actions/index.js#L70 getRegionalProjects - if this is needed, we can use the same frontend pagination approach.

cc @frozenhelium @tovari @szabozoltan69 @tnagorra

@tovari
Copy link

tovari commented Jan 25, 2024

Would you mind to review @batpad, if these still need to be resolved? Thanks.

@szabozoltan69 szabozoltan69 transferred this issue from IFRCGo/go-frontend Jan 25, 2024
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

No branches or pull requests

3 participants