<commit_before>import * as React from 'react';
import { BanEntry } from '../../BanEntry';
import { RouteComponentProps } from 'react-router';
import { getAllBansForUuid } from '../../api';
import { map } from 'ramda';
import { BanHistoryEntry } from './BanHistoryEntry';
import { NonIdealState } from '@blueprintjs/core';

type State = {
  readonly bans: BanEntry[];
  readonly error: string | null;
  readonly loading: boolean;
};

type Params = {
  readonly uuid: string;
};

export class BanHistoryPage extends React.Component<RouteComponentProps<Params>, State> {
  state = {
    bans: [],
    error: null,
    loading: true,
  };

  componentDidMount() {
    this.load();
  }

  load = async ()  => {
    this.setState({
      loading: true,
      error: null,
    });

    try {
      const bans = await getAllBansForUuid(this.props.match.params.uuid);

      this.setState({
        bans,
        error: null,
        loading: false,
      });
    } catch (err) {
      this.setState({
        error: 'Unable to fetch list from server',
        loading: false,
      });
    }
  }

  renderBans: (bans: BanEntry[]) => React.ReactElement<any>[] =
    map<BanEntry, React.ReactElement<any>>(ban => <BanHistoryEntry {...ban} key={ban.id} />);

  renderList = (): React.ReactElement<any> | React.ReactElement<any>[] => {
    if (this.state.bans.length)
      return this.renderBans(this.state.bans);
    else
      return <NonIdealState title="No bans found for UUID" visual="geosearch" />;
  }

  render() {
    return (
      <div>
        <h1>Ban History</h1>
        <small>{this.props.match.params.uuid}</small>
        {this.renderList()}
      </div>
    );
  }
}
<commit_msg>add tag to show if currently banned or not<commit_after>import * as React from 'react';
import { BanEntry } from '../../BanEntry';
import { RouteComponentProps } from 'react-router';
import { getAllBansForUuid } from '../../api';
import { map, any, CurriedFunction2, curry, propSatisfies } from 'ramda';
import { BanHistoryEntry } from './BanHistoryEntry';
import { Intent, NonIdealState, Tag } from '@blueprintjs/core';
import * as moment from 'moment';

type State = {
  readonly bans: BanEntry[];
  readonly error: string | null;
  readonly loading: boolean;
};

type Params = {
  readonly uuid: string;
};

const isAfter: CurriedFunction2<moment.Moment, moment.Moment, boolean> =
  curry((a: moment.Moment, b: moment.Moment) => b.isAfter(a));

export class BanHistoryPage extends React.Component<RouteComponentProps<Params>, State> {
  state = {
    bans: [],
    error: null,
    loading: true,
  };

  componentDidMount() {
    this.load();
  }

  load = async ()  => {
    this.setState({
      loading: true,
      error: null,
    });

    try {
      const bans = await getAllBansForUuid(this.props.match.params.uuid);

      this.setState({
        bans,
        error: null,
        loading: false,
      });
    } catch (err) {
      this.setState({
        error: 'Unable to fetch list from server',
        loading: false,
      });
    }
  }

  renderBans: (bans: BanEntry[]) => React.ReactElement<any>[] =
    map<BanEntry, React.ReactElement<any>>(ban => <BanHistoryEntry {...ban} key={ban.id} />);

  renderList = (): React.ReactElement<any> | React.ReactElement<any>[] => {
    if (this.state.bans.length)
      return this.renderBans(this.state.bans);
    else
      return <NonIdealState title="No bans found for UUID" visual="geosearch" />;
  }

  render() {
    const isBanned = any(
      propSatisfies(isAfter(moment.utc()), 'expires'),
      this.state.bans,
    );

    return (
      <div>
        <h1>Ban History</h1>
        <small>{this.props.match.params.uuid}</small>

        <h2>
          <Tag
            intent={isBanned ? Intent.DANGER : Intent.SUCCESS}
          >
            {isBanned ? 'BANNED' : (this.state.bans.length ? 'All Bans Expired' : 'Not Banned')}
          </Tag>
        </h2>

        {this.renderList()}
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.15371069182389938, 'fraction_numerical': 0.002012578616352201, 'mean_word_length': 2.6678966789667897, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 47, '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': '2130246', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1301, 'n_words': 296}