<commit_before>import { PullRequestStatus } from '../../models/pull-request'
import { APIRefState } from '../../lib/api'
import { assertNever } from '../../lib/fatal-error'

function toFriendlyText(state: APIRefState): string {
  switch (state) {
    case 'failure':
      return 'failed'
    case 'pending':
    case 'success':
      return state

    default:
      return assertNever(state, `Unknown APIRefState value: ${state}`)
  }
}

export function getPRStatusSummary(prStatus: PullRequestStatus): string {
  const statusCount = prStatus.statuses.length || 0

  if (statusCount === 0) {
    return toFriendlyText(prStatus.state)
  } else {
    const successCount = prStatus.statuses.filter(x => x.state === 'success')
      .length

    return `${successCount}/${statusCount} checks OK`
  }
}<commit_msg>:memo:<commit_after>import { PullRequestStatus } from '../../models/pull-request'
import { APIRefState } from '../../lib/api'
import { assertNever } from '../../lib/fatal-error'

function toFriendlyText(state: APIRefState): string {
  switch (state) {
    case 'failure':
      return 'failed'
    case 'pending':
    case 'success':
      return state

    default:
      return assertNever(state, `Unknown APIRefState value: ${state}`)
  }
}

/**
 * Convert the Pull Request status to an app-friendly string.
 *
 * If the pull request contains commit statuses, this method will compute
 * the number of successful statuses. Oteherwise, it will fall back
 * to the `state` value reported by the GitHub API.
 */
export function getPRStatusSummary(prStatus: PullRequestStatus): string {
  const statusCount = prStatus.statuses.length || 0

  if (statusCount === 0) {
    return toFriendlyText(prStatus.state)
  } else {
    const successCount = prStatus.statuses.filter(x => x.state === 'success')
      .length

    return `${successCount}/${statusCount} checks OK`
  }
}
{'fraction_non_alphanumeric': 0.13283740701381508, 'fraction_numerical': 0.0021253985122210413, 'mean_word_length': 3.472684085510689, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1678460', 'n_tokens_mistral': 553, 'n_tokens_neox': 552, 'n_words': 159}