<commit_before>require('react-select/dist/react-select.css')

import React, { Component } from 'react'
import Select from 'react-select'

import ChartFilters from './ChartFilters'

class ChartOptions extends Component {
  renderGroupByOptions () {
    let {columns, groupBy, handleGroupBy, selectedColumn} = this.props
    let groupableColumns
     // for GROUP_BY
    if (columns) {
      let columnKeys = Object.keys(columns)
      groupableColumns = columnKeys.filter((col) => {
        if (columns[col].key !== selectedColumn) {
          if (columns[col].categories) return true
          if (columns[col].type === 'date') return true
        }
        return false
      }).map((col) => {
        return {label: columns[col].name, value: columns[col].key}
      })
    }

    return (
      <Select
        name='groupby'
        placeholder='Select a field to group by'
        options={groupableColumns}
        value={groupBy}
        onChange={handleGroupBy}/>
      )
  }

  renderSumByOptions () {
    let {columns, handleSumBy, sumBy} = this.props
    let sumableColumns
    // for SUM_BY
    if (columns) {
      let columnKeys = Object.keys(columns)
      sumableColumns = columnKeys.filter((col) => {
        return isNumericForSum(columns[col]) || false
      }).map((col) => {
        return {label: columns[col].name, value: columns[col].key}
      })
    }

    let isNumericForSum = function (col) {
      let numberFields = ['double', 'money', 'number']
      if (numberFields.indexOf(col['type']) > -1) {
        return true
      }
      return false
    }

    return (
      <Select
        name='sumby'
        placeholder='Select a field to sum by'
        options={sumableColumns}
        value={sumBy}
        onChange={handleSumBy}/>)
  }

  render () {
    let {columns, handleAddFilter, handleRemoveFilter, filters, applyFilter, updateFilter, selectedColumn} = this.props
    let groupByOptions = null
    let sumByOptions = null

    if (columns[selectedColumn].type !== 'number') {
      groupByOptions = this.renderGroupByOptions()
      sumByOptions = this.renderSumByOptions()<commit_msg>make sure sumBy is showing up on charts except number<commit_after>require('react-select/dist/react-select.css')

import React, { Component } from 'react'
import Select from 'react-select'

import ChartFilters from './ChartFilters'

class ChartOptions extends Component {
  renderGroupByOptions () {
    let {columns, groupBy, handleGroupBy, selectedColumn} = this.props
    let groupableColumns
     // for GROUP_BY
    if (columns) {
      let columnKeys = Object.keys(columns)
      groupableColumns = columnKeys.filter((col) => {
        if (columns[col].key !== selectedColumn) {
          if (columns[col].categories) return true
          if (columns[col].type === 'date') return true
        }
        return false
      }).map((col) => {
        return {label: columns[col].name, value: columns[col].key}
      })
    }

    return (
      <Select
        name='groupby'
        placeholder='Select a field to group by'
        options={groupableColumns}
        value={groupBy}
        onChange={handleGroupBy}/>
      )
  }

  renderSumByOptions () {
    let {columns, handleSumBy, sumBy} = this.props
    let sumableColumns

    let isNumericForSum = function (col) {
      let numberFields = ['double', 'money', 'number']
      if (numberFields.indexOf(col['type']) > -1) {
        return true
      }
      return false
    }

    // for SUM_BY
    if (columns) {
      let columnKeys = Object.keys(columns)
      sumableColumns = columnKeys.filter((col) => {
        return isNumericForSum(columns[col]) || false
      }).map((col) => {
        return {label: columns[col].name, value: columns[col].key}
      })
    }

    return (
      <Select
        name='sumby'
        placeholder='Select a field to sum by'
        options={sumableColumns}
        value={sumBy}
        onChange={handleSumBy}/>)
  }

  render () {
    let {columns, handleAddFilter, handleRemoveFilter, filters, applyFilter, updateFilter, selectedColumn} = this.props
    let groupByOptions = null
    let sumByOptions = null

    if (columns[selectedColumn].type !== 'number') {
      groupByOptions = this.renderGroupByOptions()
      sumByOptions = this.renderSumByOptions()
{'fraction_non_alphanumeric': 0.121127416724901, 'fraction_numerical': 0.0004658746797111577, 'mean_word_length': 2.642069550466497, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '6622255', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1224, 'n_words': 298}