<commit_before>/**
 * LastDateModifiedContainer.jsx
 * Created by <NAME> 9/30/18
 */

import React, { PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import _ from 'lodash';

import * as lastDateModifiedActions from '../../redux/actions/lastDateModifiedActions';
import * as lastDateModifiedHelper from '../../helpers/lastDateModifiedHelper';

import CalendarRangeDatePicker from '../../components/SharedComponents/CalendarRangeDatePicker';

const propTypes = {
  setLastDateModifiedList: PropTypes.func,
  lastDateModifiedList: PropTypes.object,
  detached: PropTypes.bool,
  selectedFilters: PropTypes.object,
  type: PropTypes.string,
  table: PropTypes.string,
  placeholder: PropTypes.string,
  onSelect: PropTypes.func
};

const defaultProps = {
  setLastDateModifiedList: () => {},
  lastDateModifiedList: {},
  detached: true,
  selectedFilters: [],
  table: '',
  type: '',
  placeholder: '',
  onSelect: () => {}
};

class LastDateModifiedContainer extends React.Component {
  componentDidMount() {
    // Temporarily commented out until backend min/max dates endpoint is ready
    // this.loadData();
  }

  loadData() {
    if (_.isEmpty(this.props.lastDateModifiedList.lastDateModified)) {
      // we need to populate the list
      lastDateModifiedHelper.fetchLastDateModified()
        .then((data) => {
          const payload = [];
          data.forEach((value) => {
            payload.push(new Date(value.last_modified));
          });
          this.props.setLastDateModifiedList(payload);
        })
        .catch((err) => {
          console.error(err);
        });
    }
  }

  render() {
      // Temporarily commented out until backend min/max dates endpoint is ready
      // let values = this.props.lastDateModifiedList.lastDateModified.length > 0 ? this.props.lastDateModifiedList.lastDateModified : {};
      // Find Min/Max for last modified dates
      // if (!_.isEmpty(values)) {
      //   const finalPayload = {
      //       minDate: _.min(values),
      //       maxDate: _.max(values)
      //   };
      //   values = finalPayload;
      // }

      // Temporary min/max dates workaround until backend is ready
      const finalPayload = {
          minDate: new Date('01/01/2016'),
          maxDate: new Date(),
      };

    return (
        <CalendarRangeDatePicker minmaxDates={finalPayload} {...this.props} />
    );
  }
}

LastDateModifiedContainer.propTypes = propTypes;
LastDateModifiedContainer.defaultProps = defaultProps;

export default connect(
  (state) => ({
    lastDateModifiedList: state.lastDateModifiedList,
    selectedFilters: state.dashboardFilters
  }),
  (dispatch) => bindActionCreators(lastDateModifiedActions, dispatch),
)(LastDateModifiedContainer);
<commit_msg>removed code until backend is ready<commit_after>/**
 * LastDateModifiedContainer.jsx
 * Created by <NAME> 9/30/18
 */

import React, { PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import _ from 'lodash';

import * as lastDateModifiedActions from '../../redux/actions/lastDateModifiedActions';
import * as lastDateModifiedHelper from '../../helpers/lastDateModifiedHelper';

import CalendarRangeDatePicker from '../../components/SharedComponents/CalendarRangeDatePicker';

const propTypes = {
  setLastDateModifiedList: PropTypes.func,
  lastDateModifiedList: PropTypes.object,
  detached: PropTypes.bool,
  selectedFilters: PropTypes.object,
  type: PropTypes.string,
  table: PropTypes.string,
  placeholder: PropTypes.string,
  onSelect: PropTypes.func
};

const defaultProps = {
  setLastDateModifiedList: () => {},
  lastDateModifiedList: {},
  detached: true,
  selectedFilters: [],
  table: '',
  type: '',
  placeholder: '',
  onSelect: () => {}
};

class LastDateModifiedContainer extends React.Component {
  loadData() {
    if (_.isEmpty(this.props.lastDateModifiedList.lastDateModified)) {
      // we need to populate the list and load on mounting the component
      lastDateModifiedHelper.fetchLastDateModified()
        .then((data) => {
          const payload = [];
          data.forEach((value) => {
            payload.push(new Date(value.last_modified));
          });
          this.props.setLastDateModifiedList(payload);
        })
        .catch((err) => {
          console.error(err);
        });
    }
  }

  render() {
      // Temporary min/max dates workaround until backend is ready
      const finalPayload = {
          minDate: new Date('01/01/2016'),
          maxDate: new Date(),
      };

    return (
        <CalendarRangeDatePicker minmaxDates={finalPayload} {...this.props} />
    );
  }
}

LastDateModifiedContainer.propTypes = propTypes;
LastDateModifiedContainer.defaultProps = defaultProps;

export default connect(
  (state) => ({
    lastDateModifiedList: state.lastDateModifiedList,
    selectedFilters: state.dashboardFilters
  }),
  (dispatch) => bindActionCreators(lastDateModifiedActions, dispatch),
)(LastDateModifiedContainer);

{'fraction_non_alphanumeric': 0.12482662968099861, 'fraction_numerical': 0.005349712700614226, 'mean_word_length': 3.242016806722689, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, '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': '6957954', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1414, 'n_words': 304}