<commit_before>var PureRenderMixin = require('react/addons').addons.PureRenderMixin;
var React = require("react");

var DateTimeField = require("../../modules/datepicker/DateTimeField");

var DateSelector = React.createClass({
  contextTypes: {
    router: React.PropTypes.func
  },

  mixins: [
    PureRenderMixin
  ],

  getInitialState() {
    var dateFrom = new Date();
    dateFrom.setDate(dateFrom.getDate() - 3);
    return {
      dateFrom: dateFrom.getTime() / 1000,
      dateTo: null,
      dateType: "last_seen"
    };
  },

  onClear() {
    this.setState({
      dateFrom: null,
      dateTo: null
    });
    this.onApply(e);
  },

  onDateFromChange(value) {
    this.setState({
      dateFrom: value
    });
  },

  onDateToChange(value) {
    this.setState({
      dateTo: value
    });
  },

  onDateTypeChange(value) {
    this.setState({
      dateType: value
    });
  },

  onApply(e) {
    e.preventDefault();
    var router = this.context.router;
    var queryParams = router.getCurrentQuery();
    queryParams.until = this.state.dateTo;
    queryParams.since = this.state.dateFrom;
    queryParams.date_type = this.state.dateType;
    // TODO(dcramer): ideally we wouldn't hardcode stream here
    router.transitionTo('stream', router.getCurrentParams(), queryParams);
  },

  render() {
    return (
      <div className="dropdown btn-group">
        <a ref="toggle" className="btn btn-sm dropdown-toggle hidden-xs" data-toggle="dropdown">
          All time
          <span className="icon-arrow-down"></span>
        </a>
        <div className="datepicker-box dropdown-menu" id="daterange">
          <form method="GET">
            <div className="input">
              <DateTimeField dateTime={this.state.dateFrom} onChange={this.onDateFromChange} />
              to
              <DateTimeField dateTime={this.state.dateTo} onChange={this.onDateToChange} />
              <div className="help-block">All events are represented in UTC time.</div>
            </div>
            <div className="submit">
              <div className="pull-right">
                <button className="btn btn-default btn-sm" onClick={this.onClear}>Clear</button>
                <button className="btn btn-primary btn-sm" onClick={this.onApply}>Apply</button>
              </div>
              <div className="radio-inputs">
                <label className="radio">
                  <input type="radio" name="date_type"
                    onChange={this.onDateTypeChange.bind(this, "last_seen")}
                    checked={this.state.dateType === "last_seen"} /> Last Seen
                </label>
                <label className="radio">
                  <input type="radio" name="date_type"
                    onChange={this.onDateTypeChange.bind(this, "first_seen")}
                    checked={this.state.dateType === "first_seen"} /> First Seen
                </label>
              </div>
            </div>
          </form>
        </div>
      </div>
    );
  }
});

module.exports = DateSelector;
<commit_msg>Pass event<commit_after>var PureRenderMixin = require('react/addons').addons.PureRenderMixin;
var React = require("react");

var DateTimeField = require("../../modules/datepicker/DateTimeField");

var DateSelector = React.createClass({
  contextTypes: {
    router: React.PropTypes.func
  },

  mixins: [
    PureRenderMixin
  ],

  getInitialState() {
    var dateFrom = new Date();
    dateFrom.setDate(dateFrom.getDate() - 3);
    return {
      dateFrom: dateFrom.getTime() / 1000,
      dateTo: null,
      dateType: "last_seen"
    };
  },

  onClear(e) {
    this.setState({
      dateFrom: null,
      dateTo: null
    });
    this.onApply(e);
  },

  onDateFromChange(value) {
    this.setState({
      dateFrom: value
    });
  },

  onDateToChange(value) {
    this.setState({
      dateTo: value
    });
  },

  onDateTypeChange(value) {
    this.setState({
      dateType: value
    });
  },

  onApply(e) {
    e.preventDefault();
    var router = this.context.router;
    var queryParams = router.getCurrentQuery();
    queryParams.until = this.state.dateTo;
    queryParams.since = this.state.dateFrom;
    queryParams.date_type = this.state.dateType;
    // TODO(dcramer): ideally we wouldn't hardcode stream here
    router.transitionTo('stream', router.getCurrentParams(), queryParams);
  },

  render() {
    return (
      <div className="dropdown btn-group">
        <a ref="toggle" className="btn btn-sm dropdown-toggle hidden-xs" data-toggle="dropdown">
          All time
          <span className="icon-arrow-down"></span>
        </a>
        <div className="datepicker-box dropdown-menu" id="daterange">
          <form method="GET">
            <div className="input">
              <DateTimeField dateTime={this.state.dateFrom} onChange={this.onDateFromChange} />
              to
              <DateTimeField dateTime={this.state.dateTo} onChange={this.onDateToChange} />
              <div className="help-block">All events are represented in UTC time.</div>
            </div>
            <div className="submit">
              <div className="pull-right">
                <button className="btn btn-default btn-sm" onClick={this.onClear}>Clear</button>
                <button className="btn btn-primary btn-sm" onClick={this.onApply}>Apply</button>
              </div>
              <div className="radio-inputs">
                <label className="radio">
                  <input type="radio" name="date_type"
                    onChange={this.onDateTypeChange.bind(this, "last_seen")}
                    checked={this.state.dateType === "last_seen"} /> Last Seen
                </label>
                <label className="radio">
                  <input type="radio" name="date_type"
                    onChange={this.onDateTypeChange.bind(this, "first_seen")}
                    checked={this.state.dateType === "first_seen"} /> First Seen
                </label>
              </div>
            </div>
          </form>
        </div>
      </div>
    );
  }
});

module.exports = DateSelector;

{'fraction_non_alphanumeric': 0.1390075583305948, 'fraction_numerical': 0.001643115346697338, 'mean_word_length': 2.1835774058577404, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 67, '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': '1215489', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1743, 'n_words': 329}