0

I supposed to write an API to provide the data to the front end. I've the following screen with filters by Shift/Day/Week/Month/6Months.

Though it's completely my business logic, In general I want to know the best practice in providing data for such filters.
1) Should I provide an API for each filter on click on each tab?
With this approach, I'll have to execute db query for each time based on the filter.
2) Or, Should I provide an API once with all aggregated data with filter keys? So that from front end, client doesn't nave to invoke further API's on each click.
In this case, I'll have to execute multiple db queries at one and provide the data to the front end.

enter image description here

What is the best practice to achieve this? I know these are all part of architectural design and I'm in a learing process. Need a valid suggestion or a useful resource.

Kishore Kumar Korada
  • 1,204
  • 6
  • 22
  • 47
  • What are the constraints specially would you know the user load for that page.. – Preet Singh Aug 29 '18 at 14:51
  • @PreetSingh Didn't understand your question. But, When user load the page, By default he sees last 7 days i.e a week data. But we also have other filters. All I'm asking is, Is it a good practice to Invoke API for every filter or fetching all the data data when the page gets loaded – Kishore Kumar Korada Aug 30 '18 at 07:11

0 Answers0