<commit_before>define(['angular', 'lodash', 'imjs'], function (ng, L, im) {

  var connect = im.Service.connect;

  return ['$scope', '$log', '$timeout', '$cacheFactory', '$q', 'Mines', 'ClassUtils',
          function (scope, logger, timeout, cacheFactory, Q, mines, ClassUtils) {
    var countCache = (cacheFactory.get('query.counts') ||
                      cacheFactory('query.counts', {capacity: 100}));
    scope.defaults = {};
    scope.classes = [];
    scope.fields = [];
    scope.serviceName = "";

    scope.$on('act', function (evt) {
      scope.$emit('start-history', {
        thing: scope.rootClass.displayName + " query",
        verb: {
          ed: "ran",
          ing: "running"
        },
        tool: "show-table",
        data: {
          url: scope.connection.root,
          token: scope.connection.token,
          query: getQuery(scope)
        }
      });
    });

    scope.$on('reset', function (evt) {
      scope.rootClass = scope.defaults.rootClass;
      scope.useConstraint = false;
    });

    var fetchingDefaultMine = mines.get('default');

    scope.$watch('serviceName', function (name) {
      scope.tool.heading = 'Browse ' + name + ' by Data-Type';
    });

    scope.$watch(watchQuery, function (key) {
      var cachedN = countCache.get(key);
      if (cachedN != null) {
        setRowCount(cachedN);
      } else if (scope.connection) {
        setRowCount(null);
        scope.connection.count(getQuery(scope)).then(function (n) {
          setRowCount(countCache.put(key, n));
        });
      }
    });

    scope.$watch('rowCount', function (rowCount) {
      scope.tool.disabled = false;
      if (rowCount === 0) {
        scope.tool.disabled = true;
        scope.tool.action = "No results";
      } else if (rowCount === 1) {
        scope.tool.action = "View " + scope.rootClass.displayName;
      } else {
        scope.tool.action = "View Table";
      }
    });

    scope.$watch('rootClass.className', function (className) {
      var fields, promises;
      if (!scope.summaryFields) return;
      fields = scope.summaryFields[className];<commit_msg>Don't write to the (globally unique) tool - but to state objects<commit_after>define(['angular', 'lodash', 'imjs'], function (ng, L, im) {

  var connect = im.Service.connect;

  return ['$scope', '$log', '$timeout', '$cacheFactory', '$q', 'Mines', 'ClassUtils',
          function (scope, logger, timeout, cacheFactory, Q, mines, ClassUtils) {
    var countCache = (cacheFactory.get('query.counts') ||
                      cacheFactory('query.counts', {capacity: 100}));
    scope.defaults = {};
    scope.classes = [];
    scope.fields = [];
    scope.serviceName = "";

    scope.$on('act', function (evt) {
      scope.$emit('start-history', {
        thing: scope.rootClass.displayName + " query",
        verb: {
          ed: "ran",
          ing: "running"
        },
        tool: "show-table",
        data: {
          url: scope.connection.root,
          token: scope.connection.token,
          query: getQuery(scope)
        }
      });
    });

    scope.$on('reset', function (evt) {
      scope.rootClass = scope.defaults.rootClass;
      scope.useConstraint = false;
    });

    var fetchingDefaultMine = mines.get('default');

    scope.$watch('serviceName', function (name) {
      scope.tool.heading = 'Browse ' + name + ' by Data-Type';
    });

    scope.$watch(watchQuery, function (key) {
      var cachedN = countCache.get(key);
      if (cachedN != null) {
        setRowCount(cachedN);
      } else if (scope.connection) {
        setRowCount(null);
        scope.connection.count(getQuery(scope)).then(function (n) {
          setRowCount(countCache.put(key, n));
        });
      }
    });

    scope.$watch('rowCount', function (rowCount) {
      scope.state.disabled = false;
      if (rowCount === 0) {
        scope.state.disabled = true;
        scope.actions.act = "No results";
      } else if (rowCount === 1) {
        scope.actions.act = "View " + scope.rootClass.displayName;
      } else {
        scope.actions.act = "View Table";
      }
    });

    scope.$watch('rootClass.className', function (className) {
      var fields, promises;
      if (!scope.summaryFields) return;
      fields = scope.summaryFields[className];
{'fraction_non_alphanumeric': 0.1608016779305523, 'fraction_numerical': 0.0023304591004427873, 'mean_word_length': 2.3662745098039215, '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': '961999', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1267, 'n_words': 265}