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

Render scenario ui-grid on expand #4599

Merged
merged 7 commits into from
Apr 12, 2024
Merged

Conversation

perryr16
Copy link
Contributor

@perryr16 perryr16 commented Mar 29, 2024

Any background context you want to provide?

The Scenarios & Measures section of the inventory detail page features a table of scenarios that can be expanded to show a nested ui-grid of the associated measures. Properties with numerous scenarios/measures can experience long loading times as each scenario's ui-grid introduces watchers that can slow down angular's performance.

What's this PR do?

  • Utilizes a few ui-grid fastWatch and flatEntityAccess options to improve speed.
  • Only renders the ui-grid if a scenario row has been expanded by the user which can dramatically reduce the number of watchers on page load.

Below is some bench marking with a property that has 8 scenarios, 6 of which have 1-3 measures (10 measures total).

Description Number of Watchers
Current implementation 4200
Removing the scenarios and measures section 500
Proposed Solution 850

How should this be manually tested?

Load the property detail of a property with several scenarios/measures

What are the relevant tickets?

#4597

Screenshots (if appropriate)

@perryr16 perryr16 added the Enhancement Add this label if functionality was generally improved but not a full feature or maintentance. label Mar 29, 2024
@perryr16 perryr16 marked this pull request as ready for review April 11, 2024 19:27
@perryr16
Copy link
Contributor Author

I used the following script to count the number of watchers on the page. Just paste this into the dev tools console, no break points, just console.
source

function getWatchers(root) {
  root = angular.element(root || document.documentElement);
  var watcherCount = 0;
 
  function getElemWatchers(element) {
    var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
    var scopeWatchers = getWatchersFromScope(element.data().$scope);
    var watchers = scopeWatchers.concat(isolateWatchers);
    angular.forEach(element.children(), function (childElement) {
      watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
    });
    return watchers;
  }
  
  function getWatchersFromScope(scope) {
    if (scope) {
      return scope.$$watchers || [];
    } else {
      return [];
    }
  }
 
  return getElemWatchers(root);
}
getWatchers().length

@kflemin kflemin self-requested a review April 11, 2024 23:41
Copy link
Contributor

@kflemin kflemin left a comment

Choose a reason for hiding this comment

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

🏆

@axelstudios axelstudios merged commit 3b637c9 into develop Apr 12, 2024
9 checks passed
@axelstudios axelstudios deleted the 4597-scenario-ui-grid-watchers branch April 12, 2024 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Add this label if functionality was generally improved but not a full feature or maintentance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants