<commit_before>import { Table } from 'antd';
import autobind from 'autobind-decorator';
import PropTypes from 'prop-types';
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { push } from 'redux-little-router';
import { isEmpty, mapObject } from 'underscore';

import {
  getCurrentURL,
} from 'control_new/state/router/selectors';


@connect(
  state => ({
    getCurrentURL: queryParams => getCurrentURL(state, queryParams),
  }),
  dispatch => (
    bindActionCreators(
      {
        push,
      }, dispatch
    )
  )
)
@autobind
export default class DataList extends React.Component {
  static propTypes = {
    columnRenderers: PropTypes.object.isRequired,
    columns: PropTypes.object.isRequired,
    dataSource: PropTypes.array.isRequired,
    getCurrentURL: PropTypes.func.isRequired,
    onRowClick: PropTypes.func,
    ordering: PropTypes.string,
    push: PropTypes.func.isRequired,
  }

  static getSortOrder = (field, ordering) => {
    if (ordering && ordering.endsWith(field)) {
      return ordering.startsWith('-') ? 'descend' : 'ascend';
    }
    return false;
  }

  handleChangeSortFilters(pagination, filters, sorter) {
    const filterParams = mapObject(filters, values => values.join(',') || undefined);

    let ordering;
    if (!isEmpty(sorter)) {
      const prefix = sorter.order === 'ascend' ? '' : '-';
      ordering = `${prefix}${sorter.field}`;
    }

    this.props.push(
      this.props.getCurrentURL({
        ordering,
        ...filterParams,
      })
    );
  }

  render() {
    const { columnRenderers, columns, dataSource, onRowClick } = this.props;

    return (
      <Table
        className="list"
        dataSource={dataSource}
        pagination={false}
        rowKey="id"
        onChange={this.handleChangeSortFilters}
        onRowClick={onRowClick}
        bordered
      >
        {columns.map(column => columnRenderers[column](this.props))}
      </Table><commit_msg>Some cleanup<commit_after>import { Table } from 'antd';
import autobind from 'autobind-decorator';
import PropTypes from 'prop-types';
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { push as pushAction } from 'redux-little-router';
import { isEmpty, mapObject } from 'underscore';

import {
  getCurrentURL,
} from 'control_new/state/router/selectors';


@connect(
  state => ({
    getCurrentURL: queryParams => getCurrentURL(state, queryParams),
  }),
  dispatch => (
    bindActionCreators({
      push: pushAction,
    }, dispatch)
  )
)
@autobind
export default class DataList extends React.Component {
  static propTypes = {
    columnRenderers: PropTypes.object.isRequired,
    columns: PropTypes.object.isRequired,
    dataSource: PropTypes.array.isRequired,
    getCurrentURL: PropTypes.func.isRequired,
    onRowClick: PropTypes.func,
    ordering: PropTypes.string,
    push: PropTypes.func.isRequired,
  }

  static getSortOrder = (field, ordering) => {
    if (ordering && ordering.endsWith(field)) {
      return ordering.startsWith('-') ? 'descend' : 'ascend';
    }
    return false;
  }

  handleChangeSortFilters(pagination, filters, sorter) {
    const { getCurrentURL, push } = this.props;
    const filterParams = mapObject(filters, values => values.join(',') || undefined);

    let ordering;
    if (!isEmpty(sorter)) {
      const prefix = sorter.order === 'ascend' ? '' : '-';
      ordering = `${prefix}${sorter.field}`;
    }

    push(getCurrentURL({
      page: undefined, // Return to the first page
      ordering,
      ...filterParams,
    }));
  }

  render() {
    const { columnRenderers, columns, dataSource, onRowClick } = this.props;

    return (
      <Table
        className="list"
        dataSource={dataSource}
        pagination={false}
        rowKey="id"
        onChange={this.handleChangeSortFilters}
        onRowClick={onRowClick}
        bordered
      >
        {columns.map(column => columnRenderers[column](this.props))}
      </Table>
{'fraction_non_alphanumeric': 0.1303597831444061, 'fraction_numerical': 0.0, 'mean_word_length': 3.180226570545829, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '1371384', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1234, 'n_words': 263}