<commit_before><?php

final class PhabricatorBadgesTransaction
  extends PhabricatorApplicationTransaction {

  const TYPE_NAME = 'badges:name';
  const TYPE_DESCRIPTION = 'badges:description';
  const TYPE_QUALITY = 'badges:quality';
  const TYPE_ICON = 'badges:icon';
  const TYPE_STATUS = 'badges:status';
  const TYPE_FLAVOR = 'badges:flavor';
  const TYPE_AWARD = 'badges:award';
  const TYPE_REVOKE = 'badges:revoke';

  const MAILTAG_DETAILS = 'badges:details';
  const MAILTAG_COMMENT = 'badges:comment';
  const MAILTAG_OTHER  = 'badges:other';

  public function getApplicationName() {
    return 'badges';
  }

  public function getApplicationTransactionType() {
    return PhabricatorBadgesPHIDType::TYPECONST;
  }

  public function getApplicationTransactionCommentObject() {
    return new PhabricatorBadgesTransactionComment();
  }


  public function getTitle() {
    $author_phid = $this->getAuthorPHID();
    $object_phid = $this->getObjectPHID();

    $old = $this->getOldValue();
    $new = $this->getNewValue();

    $type = $this->getTransactionType();
    switch ($type) {
      case self::TYPE_NAME:
        if ($old === null) {
          return pht(
            '%s created this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s renamed this badge from "%s" to "%s".',
            $this->renderHandleLink($author_phid),
            $old,
            $new);
        }
        break;
      case self::TYPE_FLAVOR:
        if ($old === null) {
          return pht(
            '%s set the flavor text for this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s updated the flavor text for this badge.',
            $this->renderHandleLink($author_phid));
        }
        break;
      case self::TYPE_DESCRIPTION:
        if ($old === null) {
          return pht(
            '%s set the description for this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s updated the description for this badge.',
            $this->renderHandleLink($author_phid));
        }
        break;
      case self::TYPE_ICON:
        if ($old === null) {
          return pht(
            '%s set the icon for this badge as "%s".',
            $this->renderHandleLink($author_phid),
            $new);
        } else {
          $set = new PhabricatorBadgesIconSet();

          $icon_old = $set->getIconLabel($old);
          $icon_new = $set->getIconLabel($new);

          return pht(
            '%s updated the icon for this badge from "%s" to "%s".',
            $this->renderHandleLink($author_phid),
            $icon_old,
            $icon_new);
        }
        break;
      case self::TYPE_QUALITY:
        if ($old === null) {
          return pht(
            '%s set the quality for this badge as "%s".',
            $this->renderHandleLink($author_phid),
            $new);<commit_msg>Archiving badge needs meaningful Badge timeline event title<commit_after><?php

final class PhabricatorBadgesTransaction
  extends PhabricatorApplicationTransaction {

  const TYPE_NAME = 'badges:name';
  const TYPE_DESCRIPTION = 'badges:description';
  const TYPE_QUALITY = 'badges:quality';
  const TYPE_ICON = 'badges:icon';
  const TYPE_STATUS = 'badges:status';
  const TYPE_FLAVOR = 'badges:flavor';
  const TYPE_AWARD = 'badges:award';
  const TYPE_REVOKE = 'badges:revoke';

  const MAILTAG_DETAILS = 'badges:details';
  const MAILTAG_COMMENT = 'badges:comment';
  const MAILTAG_OTHER  = 'badges:other';

  public function getApplicationName() {
    return 'badges';
  }

  public function getApplicationTransactionType() {
    return PhabricatorBadgesPHIDType::TYPECONST;
  }

  public function getApplicationTransactionCommentObject() {
    return new PhabricatorBadgesTransactionComment();
  }


  public function getTitle() {
    $author_phid = $this->getAuthorPHID();
    $object_phid = $this->getObjectPHID();

    $old = $this->getOldValue();
    $new = $this->getNewValue();

    $type = $this->getTransactionType();
    switch ($type) {
      case self::TYPE_NAME:
        if ($old === null) {
          return pht(
            '%s created this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s renamed this badge from "%s" to "%s".',
            $this->renderHandleLink($author_phid),
            $old,
            $new);
        }
        break;
      case self::TYPE_FLAVOR:
        if ($old === null) {
          return pht(
            '%s set the flavor text for this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s updated the flavor text for this badge.',
            $this->renderHandleLink($author_phid));
        }
        break;
      case self::TYPE_DESCRIPTION:
        if ($old === null) {
          return pht(
            '%s set the description for this badge.',
            $this->renderHandleLink($author_phid));
        } else {
          return pht(
            '%s updated the description for this badge.',
            $this->renderHandleLink($author_phid));
        }
        break;
      case self::TYPE_STATUS:
        switch ($new) {
          case PhabricatorBadgesBadge::STATUS_ACTIVE:
            return pht(
              '%s activated this badge.',
              $this->renderHandleLink($author_phid));
          case PhabricatorBadgesBadge::STATUS_ARCHIVED:
            return pht(
              '%s archived this badge.',
              $this->renderHandleLink($author_phid));
        }
        break;
      case self::TYPE_ICON:
        if ($old === null) {
          return pht(
            '%s set the icon for this badge as "%s".',
            $this->renderHandleLink($author_phid),
            $new);
        } else {
          $set = new PhabricatorBadgesIconSet();

          $icon_old = $set->getIconLabel($old);
          $icon_new = $set->getIconLabel($new);

          return pht(
            '%s updated the icon for this badge from "%s" to "%s".',
            $this->renderHandleLink($author_phid),
            $icon_old,
            $icon_new);
        }
        break;
      case self::TYPE_QUALITY:
        if ($old === null) {
          return pht(
            '%s set the quality for this badge as "%s".',
            $this->renderHandleLink($author_phid),
            $new);
{'fraction_non_alphanumeric': 0.1220679012345679, 'fraction_numerical': 0.0, 'mean_word_length': 2.138498789346247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '3019531', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1898, 'n_words': 457}