<commit_before>class Click < ApplicationRecord
  belongs_to :user
  belongs_to :link, counter_cache: true

  after_create :increment_click_counts

  private

  def increment_click_counts
    words = [link.title, link.body].join(' ').scan(/[A-Za-z]+/).map(&:downcase)
    return if words.empty?
    $redis.zadd("clicks:#{id}", words.uniq.map{ |word| [words.count(word), word] })
    $redis.zunionstore('clicks', ['clicks', "clicks:#{id}"])
    $redis.expire("clicks:#{id}", 0)<commit_msg>Removed word frequency from click calculation<commit_after>class Click < ApplicationRecord
  belongs_to :user
  belongs_to :link, counter_cache: true

  after_create :increment_click_counts

  private

  def increment_click_counts
    words = [link.title, link.body].join(' ')
                                   .scan(/[A-Za-z]+/)
                                   .map(&:downcase)
                                   .uniq
                                   .map{ |word| [1, word] }
    return if words.empty?
    $redis.zadd("clicks:#{id}", words)
    $redis.zunionstore('clicks', ['clicks', "clicks:#{id}"])
    $redis.expire("clicks:#{id}", 0)
{'fraction_non_alphanumeric': 0.15432098765432098, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 2.626198083067093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6916531', 'n_tokens_mistral': 384, 'n_tokens_neox': 372, 'n_words': 69}