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

Add sorting/filtering/paginating of records based on AVA scenarios #71

Closed
blcham opened this issue Jan 8, 2024 · 8 comments · Fixed by kbss-cvut/record-manager#45 or #82
Closed
Assignees
Labels

Comments

@blcham
Copy link

blcham commented Jan 8, 2024

The list of records visualized as a table might be quite long and ADMIN user typically needs to search those records based on specific scenarios (s1, s2, s3).

Motivation in AVA:

  • there might be as many as 40000 records within ADMIN view of supplier's application
  • (s1) Most of the time, the user wants to see the last modified records on top of the table
  • (s2) Many times, the user wants to see on top only records in phase "open"
  • (s3) ADMIN user would like to filter records by organizations

Possible future/optional requirements:

  • it would be nice to have custom filtering/sorting persistent per user (at least while being logged in)
  • it would be nice to have sorting on all the attributes
  • In the long term, it would be nice to include filtering based on selected questions from a form (question is identified by origin)

Implementation proposal:

  • records should be paginated
  • headers should provide the possibility to sort alphanumerically
  • it should be possible to select phase to filter

A/C:

  • scenarios s1, s2, s3 are realizable in UI
  • UI can handle 40000 records
@blcham
Copy link
Author

blcham commented Jan 8, 2024

@ledsoft

@ledsoft ledsoft added the akaene label Jan 24, 2024
@ledsoft ledsoft self-assigned this Jan 24, 2024
@ledsoft
Copy link

ledsoft commented Jan 24, 2024

Did some research and found out the following:

  • It makes sense to restructure the RecordDto returned by the backend API to save some data. That way, we can get to approximately 640B per record. Tested by generating a file with 40k records, it has about 36MB (with the reduced RecordDto). Which is quite a lot, but it can be gzipped to hundreds to KB (I gzipped mine to 155KB, but there were quite a lot of repetitions). GZipping can be configured either directly in Spring Boot or in nginx (which is recommended).
  • Running some basic filtering on the 40k records in JS is quite fast, tens of ms at most
  • Given these findings, it seems client-side filtering and paging could work just fine data-wise. The backend may sooner start hitting limits on the query processing and result loading if there are 40k records in the repository. In that case, loading records by using paging instead of all at once could be worth investigating.
  • The main reason that could prevent doing filtering client side is whether export should work in concert with filters (that is, if filters are active, only matching records are exported) or whether all records are always exported. On the other hand, the export API already supports some basic filtering, so it would just be a question of using it and possibly extending it with additional filters (currently supported are min and max date, institution and phase).
  • Another possible reason to do backend filtering could be if there are expected to be other services that may benefit from it.
  • What would make sense even for client-side filtering is modifying the client not to fetch records every time the RecordsController is mounted either by checking whether records are already present in the client state (with the risk of showing stale data) or by using cache-based queries (If-Modified-Since header) which are, however, problematic when the backend is behind an Apache2 proxy.

ledsoft added a commit to akaene/record-manager that referenced this issue Jan 24, 2024
…data.

Also update code to the new OWL2Java constant naming strategy.
@blcham
Copy link
Author

blcham commented Jan 26, 2024

I assume:

  • by "restructure the RecordDto" you meant removing null values and user's detail as done in commit akaene/record-manager@8f5c574.
  • backend filtering is much harder to implement than frontend filtering

Based on the assumptions, I suggest the following:

  • "restructure the RecordDto" to reduce the size
  • GZipping makes sense to me only if it does not complicate viewing HTTP requests in the developer's browser (maybe the browser handles it automatically?) and it is easy (< 2h) to implement on the frontend (as I understood that the backend requires only configuration in nginx)
  • extending backend filtering is not needed. My reasoning -- I am not aware of other services besides export that could benefit from backend filtering. For the export, we might need in the future to implement filtering for a specific time period (start-date -- end-date), which I believe is already implemented on the backend. In case there is a need to implement export based on filters from frontend I would implement it in a way that the list of record IDs is used to the backend API instead of duplicating frontend filters on the backend. I assume that would not be that hard to implement.

The suggestion above does not handle filtering by form answer values. If we need it in the future, the backend API would have to be extended by filtering those values on the backend :( Including them in the record list as a flat list, not a question&answer model.

@blcham
Copy link
Author

blcham commented Jan 28, 2024

One more comparison:

  • frontend

    • pros
      • we can provide offline support in the record list in case we migrate the app to PWA
    • cons
      • very hard to extend the support for filtering by answer values
      • filtered export or other future features dependent on filtered record list would have to be implemented by sending list of record IDs (will have to use POST instead of GET)
  • backend

    • pros
      • easier to implement filtered export
      • easier to manage/test implementation of filtering in Java
    • cons
      • 1.5 bigger effort (by ML) + need to have optional in JOPA (Note, we will have to implement also pagination, sorting on the server, and sending possible sort criteria to the frontend)

@ledsoft
Copy link

ledsoft commented Jan 28, 2024

Just to clarify, backend filtering does not require support for OPTIONAL in JOPA Criteria API. It would just make the code nicer...

@blcham
Copy link
Author

blcham commented Jan 29, 2024

After discussion, we chose to implement filtering at the backend.

ledsoft added a commit to akaene/record-manager that referenced this issue Jan 31, 2024
ledsoft added a commit to akaene/record-manager that referenced this issue Jan 31, 2024
…se generic record filtering to get records from institution.
ledsoft added a commit to akaene/record-manager that referenced this issue Jan 31, 2024
ledsoft added a commit to akaene/record-manager that referenced this issue Jan 31, 2024
blcham added a commit to kbss-cvut/record-manager that referenced this issue Feb 1, 2024
[kbss-cvut/record-manager-ui#71] Reduce the size of PatientRecordDto data
ledsoft added a commit to akaene/record-manager that referenced this issue Feb 6, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 6, 2024
…eric.

This will make it reusable for record paging as well.
ledsoft added a commit to akaene/record-manager that referenced this issue Feb 6, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 6, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 6, 2024
ledsoft added a commit to akaene/record-manager that referenced this issue Feb 8, 2024
…iltering (and import) as either IRI or name.
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 8, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 8, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 8, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 8, 2024
Use intelligent-tree-select in filters.
@blcham
Copy link
Author

blcham commented Feb 9, 2024

This should not be closed yet.

@blcham blcham reopened this Feb 9, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 14, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 14, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 14, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 14, 2024
ledsoft added a commit to akaene/record-manager-ui that referenced this issue Feb 14, 2024
blcham added a commit to akaene/record-manager-ui that referenced this issue Feb 16, 2024
blcham added a commit that referenced this issue Feb 16, 2024
@ledsoft
Copy link

ledsoft commented May 15, 2024

@blcham

GZipping can be configured either directly in Spring Boot or in nginx (which is recommended).

https://docs.nginx.com/nginx/admin-guide/web-server/compression/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants