<commit_before>/* global API_HOST */
import React from 'react';
import fetch from 'isomorphic-fetch';
import { fromNow } from 'utility';
import Table from 'components/Table';

function jsonResponse(response) {
  return response.json();
}

const columns = [
  { displayName: 'key', field: 'key' },
  { displayName: 'value', field: 'value' },
];

const tableStyle = { flexGrow: 1, overflowX: 'auto', boxSizing: 'border-box', padding: '15px' };

class Status extends React.Component
{
  componentWillMount() {
    this.setState({
      loading: false,
      result: {},
    });
    fetch(`${API_HOST}/api/status`).then(jsonResponse).then(json => this.setState({ loading: false, result: json }));
  }
  render() {
    return (<div style={{ display: 'flex', flexDirection: 'row', flexWrap: 'wrap' }}>
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result)
        .filter(key => typeof (this.state.result[key]) !== 'object')
        .map(key => ({ key, value: this.state.result[key] }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.health || {})
        .map(key => ({ key, value: `${this.state.result.health[key].metric}/${this.state.result.health[key].threshold}` }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.last_added || [])
        .map(match => ({ key: match.match_id, value: fromNow(match.start_time + match.duration) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.last_parsed || [])
        .map(match => ({ key: match.match_id, value: fromNow(match.start_time + match.duration) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.retriever || [])
        .map(row => ({ key: row.hostname, value: row.count }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.queue || {})
        .map(key => ({ key, value: JSON.stringify(this.state.result.queue[key]) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.load_times || {})
        .filter(key => Number(key) >= 1000)
        .map(key => ({ key, value: JSON.stringify(this.state.result.load_times[key]) }))}
        columns={columns}
      />
    </div>);
  }
}

export default Status;<commit_msg>tweak status page<commit_after>/* global API_HOST */
import React from 'react';
import fetch from 'isomorphic-fetch';
import { fromNow, abbreviateNumber } from 'utility';
import Table from 'components/Table';

function jsonResponse(response) {
  return response.json();
}

const columns = [
  { displayName: 'key', field: 'key' },
  { displayName: 'value', field: 'value' },
];

const tableStyle = { flexGrow: 1, overflowX: 'auto', boxSizing: 'border-box', padding: '15px' };

class Status extends React.Component
{
  componentWillMount() {
    this.setState({
      loading: false,
      result: {},
    });
    fetch(`${API_HOST}/api/status`).then(jsonResponse).then(json => this.setState({ loading: false, result: json }));
  }
  render() {
    return (<div style={{ display: 'flex', flexDirection: 'row', flexWrap: 'wrap' }}>
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result)
        .filter(key => typeof (this.state.result[key]) !== 'object')
        .map(key => ({ key, value: this.state.result[key] }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.health || {})
        .map(key => ({ 
          key, 
          value: `${abbreviateNumber(this.state.result.health[key].metric)}/${abbreviateNumber(this.state.result.health[key].threshold)}`,
        }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.last_added || [])
        .map(match => ({ key: match.match_id, value: fromNow(match.start_time + match.duration) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.last_parsed || [])
        .map(match => ({ key: match.match_id, value: fromNow(match.start_time + match.duration) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={(this.state.result.retriever || [])
        .map(row => ({ key: row.hostname, value: row.count }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.queue || {})
        .map(key => ({ key, value: JSON.stringify(this.state.result.queue[key]) }))}
        columns={columns}
      />
      <Table
        style={tableStyle}
        data={Object.keys(this.state.result.load_times || {})
        .map(key => ({ key, value: this.state.result.load_times[key] }))}
        columns={columns}
      />
    </div>);
  }
}

export default Status;
{'fraction_non_alphanumeric': 0.17953321364452424, 'fraction_numerical': 0.001994813484939158, 'mean_word_length': 2.694915254237288, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 41, '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': '7298541', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1570, 'n_words': 279}