<commit_before>import * as React from 'react'

import {get, sendRequest} from '../../../utils/api/responses'

interface IIteration {
  title: string
  body?: string
  createdAt: string
}
interface IState {
  iterations?: IIteration[]
  selected?: number
}

const updatePostsList = (iterations: IIteration[]) => (_: IState) => ({
  iterations,
  selected: iterations.length - 1, // Last iteration
})

class Posts extends React.Component<{postId: number}, IState> {
  state = {
    iterations: undefined,
    selected:   undefined,
  }

  private Iteration = ({title, body, createdAt}: IIteration, k: number) => (
    <div key={k} style={this.state.selected === k ? {backgroundColor: '#eee'} : {}}>
      <h1>
        {title}
      </h1>
      <label>
        <i>
          {new Date(Date.parse(createdAt)).toLocaleString()}
        </i>
      </label>
      <p>
        {body}
      </p>
    </div>
  )

   async componentWillMount () {
    try {
      const iterations: IIteration[] = await sendRequest(get(`/api/posts/${this.props.postId}`))
      this.setState(updatePostsList(iterations))
    } catch (e) {
      console.warn(e)
    }
  }

  render () {
    return (
      <div>
        {
          this.state.iterations
          ? (this.state.iterations || []).map(this.Iteration)
          : 'Retrieving iterations...'
        }
      </div>
    )
  }
}

export default Posts
<commit_msg>Update Post page<commit_after>import * as React from 'react'

import {get, sendRequest} from '../../../utils/api/responses'

interface IIteration {
  title: string
  body?: string
  createdAt: string
}
interface IState {
  iterations?: IIteration[]
  selected?: number
}

const updatePostsList = (iterations: IIteration[]) => (_: IState) => ({
  iterations,
  selected: iterations.length - 1, // Last iteration
})

class Posts extends React.Component<{postId: number}, IState> {
  state = {
    iterations: undefined,
    selected:   undefined,
  }

  private Iteration = ({title, body, createdAt}: IIteration, k: number) => (
    <div key={k} className={`pt-card ${this.state.selected === k && 'pt-elevation-0'}`}>
      <h1>
        {title}
      </h1>
      <label>
        <i>
          {new Date(Date.parse(createdAt)).toLocaleString()}
        </i>
      </label>
      {body && body.split(`\n`).map((s, k) => <p key={k}>{s}</p>)}
    </div>
  )

   async componentWillMount () {
    try {
      const iterations: IIteration[] = await sendRequest(get(`/api/posts/${this.props.postId}`))
      this.setState(updatePostsList(iterations))
    } catch (e) {
      console.warn(e)
    }
  }

  render () {
    return (
      <div>
        {
          this.state.iterations
          ? (this.state.iterations || []).map(this.Iteration)
          : 'Retrieving iterations...'
        }
      </div>
    )
  }
}

export default Posts

{'fraction_non_alphanumeric': 0.16383581033262562, 'fraction_numerical': 0.0024769992922859165, 'mean_word_length': 2.4266666666666667, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 36, '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': '5420621', 'n_tokens_mistral': 942, 'n_tokens_neox': 928, 'n_words': 198}