<commit_before># -*- encoding: utf-8 -*-

class CfMessage < ActiveRecord::Base
  QUOTE_CHAR = "\u{ECF0}"

  self.primary_key = 'message_id'
  self.table_name  = 'cforum.messages'

  serialize :flags, ActiveRecord::Coders::Hstore

  belongs_to :owner, class_name: 'CfUser', :foreign_key => :user_id
  belongs_to :thread, class_name: 'CfThread', :foreign_key => :thread_id

  attr_accessible :message_id, :mid, :thread_id, :subject, :content,
    :author, :email, :homepage, :deleted, :user_id, :parent_id,
    :updated_at, :created_at, :upvotes, :downvotes, :forum_id, :flags

  attr_accessor :messages, :attribs

  validates :author, length: { :in => 2..60 }
  validates :subject, length: { :in => 4..64 }
  validates :content, length: { :in => 10..12288 }

  validates :email, email: true

  after_initialize do
    self.flags ||= {} if attributes.has_key? 'flags'
    self.attribs ||= {'classes' => []}
  end

  # default_scope do
  #   where("deleted = false")
  # end

  def delete_with_subtree
    update_attributes(:deleted => true)

    messages.each do |m|
      m.delete_with_subtree
    end
  end

  def restore_with_subtree
    update_attributes(:deleted => false)

    messages.each do |m|
      m.restore_with_subtree
    end
  end
end

# eof
<commit_msg>64 characters seems a little bit to less for the subject<commit_after># -*- encoding: utf-8 -*-

class CfMessage < ActiveRecord::Base
  QUOTE_CHAR = "\u{ECF0}"

  self.primary_key = 'message_id'
  self.table_name  = 'cforum.messages'

  serialize :flags, ActiveRecord::Coders::Hstore

  belongs_to :owner, class_name: 'CfUser', :foreign_key => :user_id
  belongs_to :thread, class_name: 'CfThread', :foreign_key => :thread_id

  attr_accessible :message_id, :mid, :thread_id, :subject, :content,
    :author, :email, :homepage, :deleted, :user_id, :parent_id,
    :updated_at, :created_at, :upvotes, :downvotes, :forum_id, :flags

  attr_accessor :messages, :attribs

  validates :author, length: { :in => 2..60 }
  validates :subject, length: { :in => 4..250 }
  validates :content, length: { :in => 10..12288 }

  validates :email, email: true

  after_initialize do
    self.flags ||= {} if attributes.has_key? 'flags'
    self.attribs ||= {'classes' => []}
  end

  # default_scope do
  #   where("deleted = false")
  # end

  def delete_with_subtree
    update_attributes(:deleted => true)

    messages.each do |m|
      m.delete_with_subtree
    end
  end

  def restore_with_subtree
    update_attributes(:deleted => false)

    messages.each do |m|
      m.restore_with_subtree
    end
  end
end

# eof

{'fraction_non_alphanumeric': 0.13488372093023257, 'fraction_numerical': 0.012790697674418604, 'mean_word_length': 3.7532228360957642, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5251990', 'n_tokens_mistral': 969, 'n_tokens_neox': 916, 'n_words': 216}