<commit_before>class Comment < ActiveRecord::Base
  belongs_to :user
  belongs_to :story,
    :inverse_of => :comments
  has_many :votes,
    :dependent => :delete_all
  belongs_to :parent_comment,
    :class_name => "Comment"
  has_one :moderation,
    :class_name => "Moderation"
  belongs_to :hat

  attr_accessor :current_vote, :previewing, :indent_level, :highlighted

  before_validation :on => :create do
    self.assign_short_id_and_upvote
    self.assign_initial_confidence
    self.assign_thread_id
  end
  after_create :record_initial_upvote, :mark_submitter,
    :deliver_reply_notifications, :deliver_mention_notifications,
    :log_to_countinual
  after_destroy :unassign_votes

  DOWNVOTABLE_DAYS = 7

  # after this many minutes old, a comment cannot be edited
  MAX_EDIT_MINS = (60 * 4)

  validate do
    self.comment.to_s.strip == "" &&
      errors.add(:comment, "cannot be blank.")

    self.user_id.blank? &&
      errors.add(:user_id, "cannot be blank.")

    self.story_id.blank? &&
      errors.add(:story_id, "cannot be blank.")

    (m = self.comment.to_s.strip.match(/\A(t)his([\.!])?$\z/i)) &&
      errors.add(:base, (m[1] == "T" ? "N" : "n") + "ope" + m[2].to_s)

    self.comment.to_s.strip.match(/\Atl;?dr.?$\z/i) &&
      errors.add(:base, "Wow!  A blue car!")
  end

  def self.arrange_for_user(user)
    parents = self.order("confidence DESC").group_by(&:parent_comment_id)

    # top-down list of comments, regardless of indent level
    ordered = []

    ancestors = [nil] # nil sentinel so indent_level starts at 1 without add op.
    subtree = parents[nil]
<commit_msg>user_id can be blank<commit_after>class Comment < ActiveRecord::Base
  belongs_to :user
  belongs_to :story,
    :inverse_of => :comments
  has_many :votes,
    :dependent => :delete_all
  belongs_to :parent_comment,
    :class_name => "Comment"
  has_one :moderation,
    :class_name => "Moderation"
  belongs_to :hat

  attr_accessor :current_vote, :previewing, :indent_level, :highlighted

  before_validation :on => :create do
    self.assign_short_id_and_upvote
    self.assign_initial_confidence
    self.assign_thread_id
  end
  after_create :record_initial_upvote, :mark_submitter,
    :deliver_reply_notifications, :deliver_mention_notifications,
    :log_to_countinual
  after_destroy :unassign_votes

  DOWNVOTABLE_DAYS = 7

  # after this many minutes old, a comment cannot be edited
  MAX_EDIT_MINS = (60 * 4)

  validate do
    self.comment.to_s.strip == "" &&
      errors.add(:comment, "cannot be blank.")

    self.story_id.blank? &&
      errors.add(:story_id, "cannot be blank.")

    (m = self.comment.to_s.strip.match(/\A(t)his([\.!])?$\z/i)) &&
      errors.add(:base, (m[1] == "T" ? "N" : "n") + "ope" + m[2].to_s)

    self.comment.to_s.strip.match(/\Atl;?dr.?$\z/i) &&
      errors.add(:base, "Wow!  A blue car!")
  end

  def self.arrange_for_user(user)
    parents = self.order("confidence DESC").group_by(&:parent_comment_id)

    # top-down list of comments, regardless of indent level
    ordered = []

    ancestors = [nil] # nil sentinel so indent_level starts at 1 without add op.
    subtree = parents[nil]

{'fraction_non_alphanumeric': 0.13174603174603175, 'fraction_numerical': 0.0044444444444444444, 'mean_word_length': 3.668148148148148, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '880066', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1117, 'n_words': 245}