<commit_before>/** @jsx React.DOM */
/* global document, window */
var React = require('react/addons'),
    RB = require('react-bootstrap'),
    domready = require('domready'),
    async = require('async'),
    SpectatorTiles = require('./components/SpectatorTiles'),
    apiSvc = require('./services/api');

var Spectatr = React.createClass({

  getInitialState: function(){
    return({
      players:[],
      playerFilter : ""
    });
  },

  componentDidMount: function(){
    // Why dont we use var self = this instead of .bind(this)? Seems cleaner
    var self = this;

    apiSvc.getPlayers(function (err, players) {

      async.each(players, function (player, cb) {
        apiSvc.getData(player.region, player.name, function(err, data) {
          if (err) return cb(err);
          player.gameData = data;
          return cb(null)
        });
      }, function (err) {
        if (err) return console.log(err);

        this.setState({
          players : players
        })
      }.bind(this));
    }.bind(this));
  },

  setFilter: function(e) {
    this.setState({
      playerFilter: e.target.value
    })
  },

  render: function () {
    return (
      <div className="container">
        <RB.PageHeader> {this.props.title} </RB.PageHeader>
        <RB.Row className="voffset2">
          <RB.Col sm={4} xsOffset={4}>
              <RB.Input addonBefore={<i className="fa fa-search"></i>} value={this.state.playerFilter} onChange={this.setFilter} type="search" className="form-control" placeholder="Search for Player" />
          </RB.Col>
        </RB.Row>
        <SpectatorTiles filter={this.state.playerFilter} players={this.state.players}/>
      </div>
    );
  }
});

domready(function () {
  window.React = React;
  React.render(<Spectatr title='Spectatr' />, document.body);
});<commit_msg>Added a button on page to update player data<commit_after>/** @jsx React.DOM */
/* global document, window */
var React = require('react/addons'),
    RB = require('react-bootstrap'),
    Button = RB.Button,
    domready = require('domready'),
    async = require('async'),
    SpectatorTiles = require('./components/SpectatorTiles'),
    apiSvc = require('./services/api');

var Spectatr = React.createClass({

  getInitialState: function() {
    return({
      players:[],
      playerFilter : ""
    });
  },

  updatePlayerState: function() {
    // Go back to a loading state
    this.setState({
      players: []
    });

    // Get updated player states
    var self = this;
    apiSvc.getPlayers(function (err, players) {
      async.each(players, function (player, cb) {
        apiSvc.getData(player.region, player.name, function(err, data) {
          if (err) return cb(err);
          player.gameData = data;
          return cb(null)
        });
      }, function (err) {
        if (err) return console.log(err);

        self.setState({
          players : players
        })
      });
    });
  },

  componentDidMount: function() {
    // Get state for players
    this.updatePlayerState();
  },

  setFilter: function(e) {
    this.setState({
      playerFilter: e.target.value
    })
  },

  render: function () {
    return (
      <div className="container">
        <RB.PageHeader> {this.props.title} </RB.PageHeader>
        <RB.Row className="voffset2">
          <RB.Col sm={4} xsOffset={4}>
              <RB.Input addonBefore={<div className="fa fa-search"></div>} value={this.state.playerFilter} onChange={this.setFilter} type="search" className="form-control" placeholder="Search for Player" />
          </RB.Col>
          <RB.Col xsOffset={11}>
            <Button bsStyle="primary" onClick={this.updatePlayerState}>Refresh</Button>
          </RB.Col>
        </RB.Row>
        <SpectatorTiles filter={this.state.playerFilter} players={this.state.players}/>
      </div>
    );
  }
});

domready(function () {
  window.React = React;
  React.render(<Spectatr title='Spectatr' />, document.body);
});
{'fraction_non_alphanumeric': 0.16017206477732793, 'fraction_numerical': 0.0020242914979757085, 'mean_word_length': 2.5838621940163193, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '7072637', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1202, 'n_words': 251}