<commit_before>import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';

import { states } from './constants';

import Bar from './bar';
import Map from './map';

import './main.css';

function App() {
  const [state, setState] = useState();
  const [filter, setFilter] = useState('');
  const [mode, setMode] = useState('lastedit');
  const [percentile, _setPercentile] = useState(50);
  function setPercentile(value) {
    value = parseInt(value.slice(9)) * 25;
    console.log(value);
    _setPercentile(value);
  }
  const [bounds, setBounds] = useState();
  const [boundsLoaded, setBoundsLoaded] = useState();
  const [geojson, setGeojson] = useState(null);
  const [statistics, setStatistics] = useState({});
  const [downloadLink, setDownloadLink] = useState();

  useEffect(() => {
    switch (state) {
      case states.LOADING:
        let url = `/api/getData?minx=${bounds.getWest()}&miny=${bounds.getSouth()}&maxx=${bounds.getEast()}&maxy=${bounds.getNorth()}`;
        if (filter.trim().length > 0) url += `&filter=${filter}`;
        setBoundsLoaded(bounds);
        fetch(url)
          .then((response) => {
            if (response.ok) {
              return response.json();
            }
            return response.text().then((text) => {
              throw new Error(text);
            });
          })
          .then((parsed) => {
            setGeojson(parsed);
            setDownloadLink(url);
            setState(states.LOADED);
          })
          .catch((error) => {
            if (error.message === 'ohsome') {
              setState(states.ERROR_OHSOME);
            } else {
              console.log(error);
              setState(states.ERROR);
            }
          });
        break;
      case states.ERROR:
      case states.CLEAN:
        setBoundsLoaded();
        setDownloadLink(null);
        setGeojson(null);
        break;
      case states.LOADED:
      default:
        break;
    }
    return null;
  }, [state]);

  return (
    <>
      <Bar
        state={state}
        setState={setState}
        setFilter={setFilter}
        mode={mode}
        setMode={setMode}
        percentile={percentile}
        setPercentile={setPercentile}
        statistics={statistics}
        downloadLink={downloadLink}
      />
      <Map
        state={state}
        setState={setState}
        mode={mode}
        percentile={percentile}
        setBounds={setBounds}
        boundsLoaded={boundsLoaded}
        geojson={geojson}
        setStatistics={setStatistics}
      />
    </>
  );
}
ReactDOM.render(<App />, document.getElementById('root'));
<commit_msg>Remove statistics when removing nodes<commit_after>import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';

import { states } from './constants';

import Bar from './bar';
import Map from './map';

import './main.css';

function App() {
  const [state, setState] = useState();
  const [filter, setFilter] = useState('');
  const [mode, setMode] = useState('lastedit');
  const [percentile, _setPercentile] = useState(50);
  function setPercentile(value) {
    value = parseInt(value.slice(9)) * 25;
    console.log(value);
    _setPercentile(value);
  }
  const [bounds, setBounds] = useState();
  const [boundsLoaded, setBoundsLoaded] = useState();
  const [geojson, setGeojson] = useState(null);
  const [statistics, setStatistics] = useState({});
  const [downloadLink, setDownloadLink] = useState();

  useEffect(() => {
    switch (state) {
      case states.LOADING:
        let url = `/api/getData?minx=${bounds.getWest()}&miny=${bounds.getSouth()}&maxx=${bounds.getEast()}&maxy=${bounds.getNorth()}`;
        if (filter.trim().length > 0) url += `&filter=${filter}`;
        setBoundsLoaded(bounds);
        fetch(url)
          .then((response) => {
            if (response.ok) {
              return response.json();
            }
            return response.text().then((text) => {
              throw new Error(text);
            });
          })
          .then((parsed) => {
            setGeojson(parsed);
            setDownloadLink(url);
            setState(states.LOADED);
          })
          .catch((error) => {
            if (error.message === 'ohsome') {
              setState(states.ERROR_OHSOME);
            } else {
              console.log(error);
              setState(states.ERROR);
            }
          });
        break;
      case states.ERROR:
      case states.CLEAN:
        setBoundsLoaded();
        setDownloadLink(null);
        setGeojson(null);
        setStatistics({});
        break;
      case states.LOADED:
      default:
        break;
    }
    return null;
  }, [state]);

  return (
    <>
      <Bar
        state={state}
        setState={setState}
        setFilter={setFilter}
        mode={mode}
        setMode={setMode}
        percentile={percentile}
        setPercentile={setPercentile}
        statistics={statistics}
        downloadLink={downloadLink}
      />
      <Map
        state={state}
        setState={setState}
        mode={mode}
        percentile={percentile}
        setBounds={setBounds}
        boundsLoaded={boundsLoaded}
        geojson={geojson}
        setStatistics={setStatistics}
      />
    </>
  );
}
ReactDOM.render(<App />, document.getElementById('root'));

{'fraction_non_alphanumeric': 0.147946746671667, 'fraction_numerical': 0.002250140633789612, 'mean_word_length': 2.197841726618705, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '866079', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1560, 'n_words': 293}