<commit_before>var tagsInText = (text = '') => {
  // TODO alphanumeric and underscore
  return (text.match(/#\w+/g) || []).map(str => str.substr(1))
}

var addToTaggable = (taggable, tagName, selected, trx) => {
  var association, communities
  var isPost = !taggable.post
  if (isPost) {
    // taggable is a post
    association = 'communities'
    communities = post => post.relations.communities.models
  } else {
    // taggable is a comment
    association = 'post.communities'
    communities = comment => comment.relations.post.relations.communities.models
  }
  return taggable.load(association, {transacting: trx})
  .then(() => Tag.find(tagName))
  .then(tag => {
    if (tag) {
      return tag
    } else {
      return new Tag({name: tagName}).save({}, {transacting: trx})
      .catch(() => Tag.find(tagName))
    }<commit_msg>set created_at for new tags<commit_after>var tagsInText = (text = '') => {
  // TODO alphanumeric and underscore
  return (text.match(/#\w+/g) || []).map(str => str.substr(1))
}

var addToTaggable = (taggable, tagName, selected, trx) => {
  var association, communities
  var isPost = !taggable.post
  if (isPost) {
    // taggable is a post
    association = 'communities'
    communities = post => post.relations.communities.models
  } else {
    // taggable is a comment
    association = 'post.communities'
    communities = comment => comment.relations.post.relations.communities.models
  }
  return taggable.load(association, {transacting: trx})
  .then(() => Tag.find(tagName))
  .then(tag => {
    if (tag) {
      return tag
    } else {
      return new Tag({
        name: tagName,
        created_at: new Date()
      }).save({}, {transacting: trx})
      .catch(() => Tag.find(tagName))
    }
{'fraction_non_alphanumeric': 0.15446224256292906, 'fraction_numerical': 0.0011441647597254005, 'mean_word_length': 3.048611111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2800315', 'n_tokens_mistral': 587, 'n_tokens_neox': 583, 'n_words': 137}