-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Record API should support grouping results by a given field. #216
Comments
Do we need a "grouped view" from the API? I was envisioning:
If the front end wants multiple groups, couldn't it just ask for those groups serially? I guess we could implement some kind of 'give me multiple matching sets for multiple filters' endpoint, but it seems like that logic belongs in the front-end, since it'll know (for example) how many rows it wants, or how many rows per group it wants to show, etc. |
I'd like @pavish's input on this. My concerns is that one API call per group might slow the frontend down since there's way more network requests to make (especially for groups where there's only one or two records per group... that would be 25-50 network requests for a page size of 50 records). |
Changing status until questions are resolved. |
I do not think we should do one API call per group, as this would lead to a lot of requests as @kgodey mentioned. The response eventually depends on the UX. The 'grouped view' we are discussing for the UI is basically a sorted view. It does not perform the actual 'group by' query on the db. If we do not have to show the count, we can show the 'grouped view' by using the sort functionality. In order to show the count, we will have to do point 1 of what @mathemancer mentioned (ask API for group keys based on column set, with count), but this is costly and needs to be thought out. |
@pavish we do show the count, according to the UX in the Filter, Sort, and Group tables. If we have a special API endpoint for grouped views, we can provide the count of each group from the backend. |
@kgodey That sounds good. We can have a separate API endpoint that provides only the count of each group, probably better if we have a query param to filter the groups. This will be the flow:
The reason we are not fetching all group counts at the start is because, as of now we do not have a web socket functionality to know if a table is updated. Since data may get updated, having a cached set of counts on the frontend would lead to inconsistency. |
Sounds good @pavish, I updated the main issue description. |
@kgodey Some questions before I get started on this:
|
If it wasn't grouped, we could do something like:
That would avoid problems with both database changes and variable responses. |
Awesome, I'll plan on taking in an additional |
Problem
The user should have the option to show records grouped by a given field. We need API support for the UI to show this.
Proposed solution
The API should support this use case, in addition to filtering and sorting options. See #157 and #158. Specifically, we need an API that provides group counts of various values (see comments below).
Additional context
As part of this issue, we'll need to define what a grouped API response looks like. Please update the API standards with details and request review from @kgodey and @mathemancer before proceeding.
The text was updated successfully, but these errors were encountered: