<commit_before>'use strict';

import React from 'react';
import IssuesList from 'components/molecules/issues_list/IssuesList';
import IssuesTabs from 'components/molecules/issues_tabs/IssuesTabs';
import Tab from 'components/atoms/tab/Tab';
import Github from 'github-api';
import GithubQueryBuilder from '../../helpers/GithubQueryBuilder';

_ = require('lodash');
require('./stylesheets/main.scss');

class Main extends React.Component {
  constructor(props) {
    super(props);
    // TODO associate creation of query with tab passing the value on the constructor
    this.state = {issues: [], activeTab: 'hot', githubQuery: new GithubQueryBuilder()};
  }
  setGithubQuery() {
    this.state.githubQuery.applyFilter(tab);
  }
  componentDidMount() {
    this.requestGithub();
  }
  changeTab(tab) {
    this.setState({activeTab: tab});
    this.state.githubQuery.applyFilter(tab);
    this.requestGithub();
  }
  requestGithub() {
    let github = new Github({});
    let search = github.getSearch(this.state.githubQuery.getQuery());
    var that = this;

    search.issues(null, function(err, issues) {
      var oldIssues = that.state.issues;

      // oldIssues.push(...issues.items);
      that.setState({
        issues: issues.items
      });
      console.log(oldIssues[0]);
      console.log(oldIssues[1]);
    });
  }
  render() {
    return (
      <div className='main-component column'>
        <div className='issues-tabs-component'>
          <header>
            <h4>{_.capitalize(this.state.activeTab)} Issues</h4>
          </header>
          <div className='row tabs'>
            <Tab name='hot' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab}/>
            <Tab name='trending' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab} />
            <Tab name='fresh' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab} />
          </div>
        </div>
        <IssuesList issues={this.state.issues} activeTab={this.state.activeTab}/>
      </div>
    );<commit_msg>change function to arrow function to remove "that", that is ugly<commit_after>'use strict';

import React from 'react';
import IssuesList from 'components/molecules/issues_list/IssuesList';
import IssuesTabs from 'components/molecules/issues_tabs/IssuesTabs';
import Tab from 'components/atoms/tab/Tab';
import Github from 'github-api';
import GithubQueryBuilder from '../../helpers/GithubQueryBuilder';

_ = require('lodash');
require('./stylesheets/main.scss');

class Main extends React.Component {
  constructor(props) {
    super(props);
    // TODO associate creation of query with tab passing the value on the constructor
    this.state = {issues: [], activeTab: 'hot', githubQuery: new GithubQueryBuilder()};
  }
  setGithubQuery() {
    this.state.githubQuery.applyFilter(tab);
  }
  componentDidMount() {
    this.requestGithub();
  }
  changeTab(tab) {
    this.setState({activeTab: tab});
    this.state.githubQuery.applyFilter(tab);
    this.requestGithub();
  }
  requestGithub() {
    let github = new Github({});
    let search = github.getSearch(this.state.githubQuery.getQuery());
    var that = this;

    search.issues(null, (err, issues) => {
      var oldIssues = this.state.issues;

      // oldIssues.push(...issues.items);
      this.setState({
        issues: issues.items
      });
      console.log(oldIssues[0]);
      console.log(oldIssues[1]);
    });
  }
  render() {
    return (
      <div className='main-component column'>
        <div className='issues-tabs-component'>
          <header>
            <h4>{_.capitalize(this.state.activeTab)} Issues</h4>
          </header>
          <div className='row tabs'>
            <Tab name='hot' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab}/>
            <Tab name='trending' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab} />
            <Tab name='fresh' onClick={this.changeTab.bind(this)} activeTab={this.state.activeTab} />
          </div>
        </div>
        <IssuesList issues={this.state.issues} activeTab={this.state.activeTab}/>
      </div>
    );
{'fraction_non_alphanumeric': 0.14898255813953487, 'fraction_numerical': 0.001937984496124031, 'mean_word_length': 3.213265306122449, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 32, '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': '7304593', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1240, 'n_words': 246}