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

Load data dictionary case properties in chunks #34827

Merged
merged 18 commits into from
Jul 29, 2024
Merged

Conversation

kaapstorm
Copy link
Contributor

@kaapstorm kaapstorm commented Jun 27, 2024

Product Description

Improves the performance of the Data Dictionary page for projects with high numbers of case types and case properties.

Technical Summary

Context:

This change allows the data dictionary to support tens of thousands of case properties. It does this by fetching only the case properties of the selected case type, and by chunking the case properties over multiple requests if there are a lot.

This change builds on work currently in open PRs. Commits are rebased as follows:

  1. master
  2. ze/dd-only-save-changed-props (PR Only Save Changed Case Properties in Data Dictionary #34781 )
  3. ay/data-dict-chunk-load (PR New view for Data Dict JSON to support chunk load #34787 )
  4. These new commits, starting with "propertyListItem and groupsViewModel subscribe"

Feature Flag

N/A. Available on all plans with Data Dictionary.

Safety Assurance

Safety story

  • Tested locally
  • Tested on Staging

Automated test coverage

Code changes are in JavaScript viewmodels and not covered by tests.

QA Plan

QA ticket: QA-6727

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@kaapstorm kaapstorm requested a review from mkangia June 27, 2024 11:01
@kaapstorm kaapstorm force-pushed the ay+ze+nh/dd_chunked branch 2 times, most recently from d5f143f to 042bf8c Compare June 28, 2024 03:00
@kaapstorm kaapstorm requested a review from ajeety4 June 28, 2024 15:56
@kaapstorm kaapstorm added the product/all-users-all-environments Change impacts all users on all environments label Jun 28, 2024
@kaapstorm kaapstorm marked this pull request as ready for review June 28, 2024 16:00
@kaapstorm kaapstorm force-pushed the ay+ze+nh/dd_chunked branch from b746e0d to f41c020 Compare July 3, 2024 12:25
@kaapstorm kaapstorm force-pushed the ay+ze+nh/dd_chunked branch from b0793f6 to a9428b2 Compare July 14, 2024 00:10
@kaapstorm
Copy link
Contributor Author

I am sorry for the rebase, but I hope it makes it easier to review now that the base branches are merged.

self.isGeoCaseProp = ko.observable(isGeoCaseProp);
self.isSafeToDelete = ko.observable(isSafeToDelete);
self.isSafeToDelete = ko.observable(prop.isSafeToDelete);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data that we pass as prop to this model has the field for is safe to delete stored as is_safe_to_delete and not isSafeToDelete. We'll need to change that here to correctly fetch the value. This should resolve the bug where the delete button is not showing.

@zandre-eng
Copy link
Contributor

After looking at the code, it seems that groups with no case properties won't be loaded to the front-end because of what's happening here in the view. Specifically, a query is done on case properties, fetching related groups. Any groups without case properties will therefore not be in the query.

@zandre-eng
Copy link
Contributor

Happy to approve once this has been given a final test pass on staging.

@kaapstorm
Copy link
Contributor Author

Deployed to staging.

@zandre-eng do you mean that you or I can check this on Staging, or that the QA Team should give this another pass?

The QA Team's domain is here: https://staging.commcarehq.org/a/qateam/data_dictionary/

The QA ticket is here: https://dimagi.atlassian.net/browse/QA-6727

@zandre-eng
Copy link
Contributor

@kaapstorm I think if QA is able to do a final pass then that should be fine.

self.groups.push(groupObj);
}
};

self.fetchCaseProperties = function () {
if (self.groups().length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admittedly don't have a lot of context around the data dictionary, hence me asking this: what is the group in this context and why do we check whether there is a group here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user selects a case type, the viewmodel fetches its case properties.

The server returns the CaseProperty instances nested in their CasePropertyGroup instances ("data.groups" on line 96). (The CaseProperty instances that don't have a CasePropertyGroup are nested in a group with an empty name.)

So if self.groups() does not have a value, it means that the viewmodel has not fetched its case properties already, so it should do that now.

Copy link
Contributor

@zandre-eng zandre-eng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA has passed on this PR, and so all looks good from my end to approve.

@kaapstorm kaapstorm merged commit 2755495 into master Jul 29, 2024
13 checks passed
@kaapstorm kaapstorm deleted the ay+ze+nh/dd_chunked branch July 29, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/all-users-all-environments Change impacts all users on all environments QA Passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants