<commit_before># FIX: serialization of self.hearts

class Experience < ActiveRecord::Base
  extend FriendlyId

  friendly_id :title, use: :slugged

  validates :body, uniqueness: true, presence: true

  before_save :defaults

  default_scope {order('created_at DESC')}

  def self.random
    order('RANDOM()').first
  end

  def defaults
    self.pseudonym ||= 'anonymous'
    self.title ||= 'untitled experience'
  end

  def grouped_rating
    hearts.inject({}) do |hash, rating|
      hash[rating].nil? ? hash[rating] = 1 : hash[rating] += 1
      hash
    end
  end
end
<commit_msg>Fixes the Experience#random issue.<commit_after># FIX: serialization of self.hearts

class Experience < ActiveRecord::Base
  extend FriendlyId

  friendly_id :title, use: :slugged

  validates :body, uniqueness: true, presence: true

  before_save :defaults

  default_scope {order('created_at DESC')}

  def self.random
    Experience.find Experience.ids.sample
  end

  def defaults
    self.pseudonym ||= 'anonymous'
    self.title ||= 'untitled experience'
  end

  def grouped_rating
    hearts.inject({}) do |hash, rating|
      hash[rating].nil? ? hash[rating] = 1 : hash[rating] += 1
      hash
    end
  end
end

{'fraction_non_alphanumeric': 0.10770505385252693, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 3.5757575757575757, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '480886', 'n_tokens_mistral': 400, 'n_tokens_neox': 381, 'n_words': 108}