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.
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.