<commit_before>/**
 * This controller is responsible for building graph from current route
 */
require('./graphViewer');

module.exports = function ($scope, $routeParams, $http, $location) {
  $scope.name = ' ' + $routeParams.pkgId;
  $scope.root = $routeParams.pkgId;
  $scope.onNodeSelected = selectPackage;
  $scope.switchMode = function () {
    $location.path('view/3d/' + $routeParams.pkgId);
  };

  var graphBuilder = require('../graphBuilder')($routeParams.pkgId, $http);
  $scope.graph = graphBuilder.graph;
  graphBuilder.start.then(function () {
    // todo: check if it supports webgl
    if(!$scope.$$phase) {
      $scope.$apply(function () { $scope.canSwitchMode = true;});
    } else {
      $scope.canSwitchMode = true;
    }
  });

  function selectPackage(node) {
    $scope.$apply(function () {
      $scope.selectedPackage = node.data;
    });
  }
};
<commit_msg>Autoselect root<commit_after>/**
 * This controller is responsible for building graph from current route
 */
require('./graphViewer');

module.exports = function($scope, $routeParams, $http, $location) {
  $scope.name = ' ' + $routeParams.pkgId;
  $scope.root = $routeParams.pkgId;
  $scope.onNodeSelected = selectPackage;
  $scope.switchMode = function() {
    $location.path('view/3d/' + $routeParams.pkgId);
  };

  var graphBuilder = require('../graphBuilder')($routeParams.pkgId, $http);
  $scope.graph = graphBuilder.graph;
  graphBuilder.start.then(function() {
    // todo: check if it supports webgl
    if (!$scope.$$phase) {
      $scope.$apply(function() {
        $scope.canSwitchMode = true;
      });
    } else {
      $scope.canSwitchMode = true;
    }
    var root = graphBuilder.graph.getNode($scope.root);
    if (root) {
      selectPackage(root);
    }
  });

  function selectPackage(node) {
    if (!$scope.$$phase) {
      $scope.$apply(function() {
        $scope.selectedPackage = node.data;
      });
    } else {
      $scope.selectedPackage = node.data;
    }
  }
};

{'fraction_non_alphanumeric': 0.16599394550958627, 'fraction_numerical': 0.0010090817356205853, 'mean_word_length': 3.2371794871794872, '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': '7052278', 'n_tokens_mistral': 630, 'n_tokens_neox': 627, 'n_words': 118}