<commit_before>import React, { Component, PropTypes } from 'react';
import { Grid, Row, Col } from 'react-flexbox-grid/lib/index';
import RaisedButton from 'material-ui/RaisedButton';
import _ from 'lodash';
import TracksDownloadTable from './TracksDownloadTable';

export default class TrackProcessing extends Component {
  static propTypes = {
    tracks: PropTypes.object.isRequired,
    tracksSearch: PropTypes.object.isRequired,
    trackDownloads: PropTypes.object.isRequired,
    trackActions: PropTypes.object.isRequired
  };
  constructor(props) {
    super(props);
    this.searchTracks = this.searchTracks.bind(this);
    this.getSelectedTracks = this.getSelectedTracks.bind(this);
  }
  searchTracks(e) {
    e.preventDefault();
    let searchTrack = this.props.trackActions.searchTrack;
    let tracksSearch = this.props.tracksSearch;
    _.each(this.getSelectedTracks(), (track) => {
      if (tracksSearch[track.id] === undefined || tracksSearch[track.id].error !== null){
        searchTrack(track)
      }
    });
  }
  getSelectedTracks() {
    let selectedTracks = [];
    _.each(this.props.tracks, (track) => {
      if(track.isSelected) selectedTracks.push(track);
    });
    return selectedTracks;
  }
  render() {
    return (
      <Grid>
        <Row>
          <Col mdOffset={10} md={2}>
            <RaisedButton label="Search all tracks..." primary onClick={this.searchTracks}/>
          </Col>
        </Row><commit_msg>Add download all button.<commit_after>import React, { Component, PropTypes } from 'react';
import { Grid, Row, Col } from 'react-flexbox-grid/lib/index';
import RaisedButton from 'material-ui/RaisedButton';
import _ from 'lodash';
import TracksDownloadTable from './TracksDownloadTable';

export default class TrackProcessing extends Component {
  static propTypes = {
    tracks: PropTypes.object.isRequired,
    tracksSearch: PropTypes.object.isRequired,
    trackDownloads: PropTypes.object.isRequired,
    trackActions: PropTypes.object.isRequired
  };
  constructor(props) {
    super(props);
    this.searchTracks = this.searchTracks.bind(this);
    this.getSelectedTracks = this.getSelectedTracks.bind(this);
  }
  downloadTracks(e) {
    e.preventDefault();
    let downloadTrack = this.props.trackActions.downloadTrack;
    let trackDownloads = this.props.trackDownloads;
    let tracksSearch = this.props.tracksSearch;
    _.each(this.getSelectedTracks(), (track) => {
      if (trackDownloads[track.id] === undefined || trackDownloads[track.id].error !== null){
        let trackSearchInfo = tracksSearch[track.id];
        downloadTrack({id: track.id, url: trackSearchInfo.results[0].url});
      }
    });
  }
  searchTracks(e) {
    e.preventDefault();
    let searchTrack = this.props.trackActions.searchTrack;
    let tracksSearch = this.props.tracksSearch;
    _.each(this.getSelectedTracks(), (track) => {
      if (tracksSearch[track.id] === undefined || tracksSearch[track.id].error !== null){
        searchTrack(track)
      }
    });
  }
  getSelectedTracks() {
    let selectedTracks = [];
    _.each(this.props.tracks, (track) => {
      if(track.isSelected) selectedTracks.push(track);
    });
    return selectedTracks;
  }
  render() {
    return (
      <Grid>
        <Row>
          <Col>
            <RaisedButton label="Search all" primary onClick={this.searchTracks}/>
            <RaisedButton label="Download all" secondary onClick={this.downloadTracks}/>
          </Col>
        </Row>
{'fraction_non_alphanumeric': 0.13126079447322972, 'fraction_numerical': 0.0011514104778353484, 'mean_word_length': 3.4155019059720457, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '118160', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1030, 'n_words': 199}