<commit_before>define(function (require) {

  var React = require('react'),
      Backbone = require('backbone'),
      stores = require('stores'),
      actions = require('actions'),
      // plugin: jquery extension, not used directly
      bootstrap = require('bootstrap');

  function randomIntFromInterval(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min);
  }

  return React.createClass({

    getInitialState: function(){
      return {
        isRefreshing: false
      }
    },

    componentDidMount: function(){
      this.generateTooltip();
    },

    componentDidUpdate: function(){
      this.generateTooltip();
    },

    generateTooltip: function(){
      var el = this.getDOMNode();
      var $el = $(el);
      $el.tooltip({
        title: "Force a refresh"
      });
    },

    handleRefresh: function(){
      var instances = stores.InstanceStore.getAll(),
          volumes = stores.VolumeStore.getAll(),
          refreshTime = randomIntFromInterval(5,10);

      // show the user something so they think the resources are polling...
      this.setState({isRefreshing: true});
      setTimeout(function(){
        this.setState({isRefreshing: false});
      }.bind(this), refreshTime*1000);

      // now actually poll the instances and volumes
      instances.each(function(instance){
        actions.InstanceActions.poll({instance: instance});
      });

      volumes.each(function(volume){
        actions.VolumeActions.poll({volume: volume});
      });
    },

    render: function () {
      var className = "glyphicon glyphicon-refresh";
      if(this.state.isRefreshing) className += " refreshing";

      return (
        <button className="btn btn-default" onClick={this.handleRefresh} disabled={this.state.isRefreshing}>
          <i className={className}/>
        </button>
      );
    }

  });

});
<commit_msg>fix React error when component not mounted<commit_after>define(function (require) {

  var React = require('react'),
      Backbone = require('backbone'),
      stores = require('stores'),
      actions = require('actions'),
      // plugin: jquery extension, not used directly
      bootstrap = require('bootstrap');

  function randomIntFromInterval(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min);
  }

  return React.createClass({

    getInitialState: function(){
      return {
        isRefreshing: false
      }
    },

    componentDidMount: function(){
      this.generateTooltip();
    },

    componentDidUpdate: function(){
      this.generateTooltip();
    },

    generateTooltip: function(){
      var el = this.getDOMNode();
      var $el = $(el);
      $el.tooltip({
        title: "Force a refresh"
      });
    },

    handleRefresh: function(){
      var instances = stores.InstanceStore.getAll(),
          volumes = stores.VolumeStore.getAll(),
          refreshTime = randomIntFromInterval(5,10);

      // show the user something so they think the resources are polling...
      this.setState({isRefreshing: true});
      setTimeout(function(){
        if (this.isMounted()) this.setState({isRefreshing: false});
      }.bind(this), refreshTime*1000);

      // now actually poll the instances and volumes
      instances.each(function(instance){
        actions.InstanceActions.poll({instance: instance});
      });

      volumes.each(function(volume){
        actions.VolumeActions.poll({volume: volume});
      });
    },

    render: function () {
      var className = "glyphicon glyphicon-refresh";
      if(this.state.isRefreshing) className += " refreshing";

      return (
        <button className="btn btn-default" onClick={this.handleRefresh} disabled={this.state.isRefreshing}>
          <i className={className}/>
        </button>
      );
    }

  });

});

{'fraction_non_alphanumeric': 0.1370691923178111, 'fraction_numerical': 0.004209418574059458, 'mean_word_length': 2.6487523992322455, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4157516', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1024, 'n_words': 232}