<commit_before>'use strict';

angular.module('ngDependencyGraph')
  .controller('MainCtrl', function($scope, $timeout, dev, Graph, Const, currentView, inspectedApp, storage) {
    var ctrl = this;
    
    $scope.currentView = currentView;

    function init(isTheSameApp) {
      var rawData = inspectedApp.getData();

      _.each(rawData.modules, function(module) {
          module.type = 'module';
        
          _.each(module.components, function(com) {
              com._module = module;
          });
      });

      var allComponents = [];
      _.each(rawData.modules, function(module) {
        allComponents = allComponents.concat(module.components);
      });

      var componentsGraph = Graph.createFromRawNodes(allComponents, Const.Scope.COMPONENTS);
      var modulesGraph = Graph.createFromRawNodes(rawData.modules, Const.Scope.MODULES);

      /**
       * Connect modules with components
       */
      _.each(componentsGraph.nodes, function(com) {
        var module = _.find(modulesGraph.nodes, {name: com._data._module.name});
        com.module = module;

        module.componentsByType = module.componentsByType || {};
        if (module.componentsByType[com.type] === undefined) {
          module.componentsByType[com.type] = [];
        }
        module.componentsByType[com.type].push(com);

      });

      currentView.setGraphs(modulesGraph, componentsGraph);

      var appNode = _.find(modulesGraph.nodes, {name: rawData.apps[0]});

      storage.loadCurrentView().then(function() {
        currentView.chooseNode(appNode);

        currentView.setScope(currentView.scope);
        // TODO meeeh not .setScope here... REFACTOR, setScope should just set scope, not initialise graph
        currentView.applyFilters();

      }, function() {
        currentView.chooseNode(appNode);
      });

      // TODO possible racecondition with saveCurrentView !!!
      // $timeout(function() {
      //   currentView.chooseNode(appNode);
      // });

    }
<commit_msg>formatting<commit_after>'use strict';

angular.module('ngDependencyGraph')
  .controller('MainCtrl', function($scope, $timeout, dev, Graph, Const, currentView, inspectedApp, storage) {
    var ctrl = this;
    
    $scope.currentView = currentView;

    function init(isTheSameApp) {
      var rawData = inspectedApp.getData();

      _.each(rawData.modules, function(module) {
          module.type = 'module';
        
          _.each(module.components, function(com) {
              com._module = module;
          });
      });

      var allComponents = [];
      _.each(rawData.modules, function(module) {
        allComponents = allComponents.concat(module.components);
      });

      var componentsGraph = Graph.createFromRawNodes(allComponents, Const.Scope.COMPONENTS);
      var modulesGraph = Graph.createFromRawNodes(rawData.modules, Const.Scope.MODULES);

      /**
       * Connect modules with components
       */
      _.each(componentsGraph.nodes, function(com) {
        var module = _.find(modulesGraph.nodes, {name: com._data._module.name});
        com.module = module;

        module.componentsByType = module.componentsByType || {};
        if (module.componentsByType[com.type] === undefined) {
          module.componentsByType[com.type] = [];
        }
        module.componentsByType[com.type].push(com);

      });

      currentView.setGraphs(modulesGraph, componentsGraph);

      var appNode = _.find(modulesGraph.nodes, {name: rawData.apps[0]});

      storage.loadCurrentView().then(function() {
        currentView.chooseNode(appNode);
        currentView.setScope(currentView.scope);
        // TODO meeeh not .setScope here... REFACTOR, setScope should just set scope, not initialise graph
        currentView.applyFilters();
      }, function() {
        currentView.chooseNode(appNode);
      });

      // TODO possible racecondition with saveCurrentView !!!
      // $timeout(function() {
      //   currentView.chooseNode(appNode);
      // });
    }

{'fraction_non_alphanumeric': 0.1285, 'fraction_numerical': 0.0005, 'mean_word_length': 2.6841620626151013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5188737', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1087, 'n_words': 196}