<commit_before>import React, { Component } from 'react';
import ModuleSelector from './moduleSelector';
import ChangesetArea from './changesetArea';
import ResultArea from './resultArea';

import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';

const muiTheme = getMuiTheme({

});

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      modules: [
        "foundations",
        "foundations\\options\\database",
        "foundations\\options\\licensing",
        "aim",
        "findings",
        "hl7",
        "service",
        "core",
        "service\\options\\licensing",
        "workflow",
        "datastorage",
        "dicom",
        "imaging",
        "lco",
        "organizer",
        "cip",
        "itf",
      ],
      module: "foundations",
      changesets: [],
      selectedRows: [],
      lastSelectedRows: [],
      queryDisabled: true,
      result: "",
    };
  }

  handleModuleChange(event, index, value) {
    var updatedState = Object.assign({}, this.state, {
      module: value,
      changesets: [],
      queryDisabled: true,
      selectedRows: [],
      result: "waiting for changesets..."
    });
    this.setState(updatedState);
    console.log(`querying history for ${this.state.modules[value]}`);
    fetch(`/tf/history?module=${this.state.modules[value]}`)
      .then((response) => {
        var contentType = response.headers.get("Content-Type");
        if (contentType && contentType.includes("application/json")) {
          return response.json();
        }
        throw new TypeError(`Oops, we haven't got JSON as response to the history query! We have got ${contentType}`);
      })
      .then((json) => {
        var changesets = json.changesets;
        console.log(`${changesets.length} changesets received`);
        updatedState = Object.assign({}, this.state, {
          changesets: json.changesets,
          result: ""
        });
        this.setState(updatedState);
      })
      .catch((error) => { console.log(error); });
  }

  handleChangesetSelection(selectedRows) {
    var last = selectedRows;
    if (selectedRows.length === 0) last = this.state.selectedRows;
    console.log(last);
    this.setState({
      selectedRows: selectedRows,
      lastSelectedRows: last,
      queryDisabled: selectedRows.length < 1
    });
  }

  startQuery = () => {
    var updatedState = Object.assign({}, this.state, {
      result: "waiting for result...",
      queryDisabled: true,
      selectedRows: this.state.lastSelectedRows
    });
    this.setState(updatedState);
    var css = [];
    for (var i = 0; i < this.state.lastSelectedRows.length; i++) {
      css.push(this.state.changesets[this.state.lastSelectedRows[i]].id);
    }
    var changesets = css.join();
    fetch(`/tf/wxsimpact?module=${this.state.modules[this.state.module]}&changesets=${changesets}`)
      .then((response) => {
        var contentType = response.headers.get("Content-Type");
        if (contentType && contentType.includes("application/json")) {
          return response.json();
        }
        throw new TypeError(`Oops, we haven't got JSON as response to the history query! We have got ${contentType}`);
      })
      .then((json) => {
        console.log(json.result);
        updatedState = Object.assign({}, this.state, {
          result: json.result,
          queryDisabled: false
        });
        this.setState(updatedState);
      })
      .catch((error) => { console.log(error); });
  }

  render() {
    console.log(this.state.result)
    return (
      <MuiThemeProvider muiTheme={muiTheme}>
        <div className="App">
          <ModuleSelector
            modules={this.state.modules}
            value={this.state.module}
            handleChange={(e, i, v) => this.handleModuleChange(e, i, v)}
          />
          <ChangesetArea
            changesets={this.state.changesets}
            selectedRows={this.state.selectedRows}
            handleSelection={(s) => this.handleChangesetSelection(s)}
          />
          <ResultArea
            disabled={this.queryDisabled}
            startQuery={() => this.startQuery()}
            result={this.state.result}
          />
        </div>
      </MuiThemeProvider>
    );
  }
}
<commit_msg>bugfix: result was sometimes a string, other times an array<commit_after>import React, { Component } from 'react';
import ModuleSelector from './moduleSelector';
import ChangesetArea from './changesetArea';
import ResultArea from './resultArea';

import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';

const muiTheme = getMuiTheme({

});

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      modules: [
        "foundations",
        "foundations\\options\\database",
        "foundations\\options\\licensing",
        "aim",
        "findings",
        "hl7",
        "service",
        "core",
        "service\\options\\licensing",
        "workflow",
        "datastorage",
        "dicom",
        "imaging",
        "lco",
        "organizer",
        "cip",
        "itf",
      ],
      module: "foundations",
      changesets: [],
      selectedRows: [],
      lastSelectedRows: [],
      queryDisabled: true,
      result: [],
    };
  }

  handleModuleChange(event, index, value) {
    var updatedState = Object.assign({}, this.state, {
      module: value,
      changesets: [],
      queryDisabled: true,
      selectedRows: [],
      result: ["waiting for changesets..."]
    });
    this.setState(updatedState);
    console.log(`querying history for ${this.state.modules[value]}`);
    fetch(`/tf/history?module=${this.state.modules[value]}`)
      .then((response) => {
        var contentType = response.headers.get("Content-Type");
        if (contentType && contentType.includes("application/json")) {
          return response.json();
        }
        throw new TypeError(`Oops, we haven't got JSON as response to the history query! We have got ${contentType}`);
      })
      .then((json) => {
        var changesets = json.changesets;
        console.log(`${changesets.length} changesets received`);
        updatedState = Object.assign({}, this.state, {
          changesets: json.changesets,
          result: []
        });
        this.setState(updatedState);
      })
      .catch((error) => { console.log(error); });
  }

  handleChangesetSelection(selectedRows) {
    var last = selectedRows;
    if (selectedRows.length === 0) last = this.state.selectedRows;
    this.setState({
      selectedRows: selectedRows,
      lastSelectedRows: last,
      queryDisabled: selectedRows.length < 1
    });
  }

  startQuery = () => {
    var updatedState = Object.assign({}, this.state, {
      result: ["waiting for result..."],
      queryDisabled: true,
      selectedRows: this.state.lastSelectedRows
    });
    this.setState(updatedState);
    var css = [];
    for (var i = 0; i < this.state.lastSelectedRows.length; i++) {
      css.push(this.state.changesets[this.state.lastSelectedRows[i]].id);
    }
    var changesets = css.join();
    fetch(`/tf/wxsimpact?module=${this.state.modules[this.state.module]}&changesets=${changesets}`)
      .then((response) => {
        var contentType = response.headers.get("Content-Type");
        if (contentType && contentType.includes("application/json")) {
          return response.json();
        }
        throw new TypeError(`Oops, we haven't got JSON as response to the history query! We have got ${contentType}`);
      })
      .then((json) => {
        console.log(`received data as wxs impact: ${json.result}`);
        updatedState = Object.assign({}, this.state, {
          result: json.result.length > 0 ? json.result : ["no wxs impact detected"],
          queryDisabled: false
        });
        this.setState(updatedState);
      })
      .catch((error) => { console.log(error); });
  }

  render() {
    console.log(this.state.result)
    return (
      <MuiThemeProvider muiTheme={muiTheme}>
        <div className="App">
          <ModuleSelector
            modules={this.state.modules}
            value={this.state.module}
            handleChange={(e, i, v) => this.handleModuleChange(e, i, v)}
          />
          <ChangesetArea
            changesets={this.state.changesets}
            selectedRows={this.state.selectedRows}
            handleSelection={(s) => this.handleChangesetSelection(s)}
          />
          <ResultArea
            disabled={this.queryDisabled}
            startQuery={() => this.startQuery()}
            result={this.state.result}
          />
        </div>
      </MuiThemeProvider>
    );
  }
}

{'fraction_non_alphanumeric': 0.14597296376235375, 'fraction_numerical': 0.0010223787345223219, 'mean_word_length': 2.3992277992277993, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 38, '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': '6050782', 'n_tokens_mistral': 2506, 'n_tokens_neox': 2506, 'n_words': 499}