<commit_before>class Node < ActiveRecord::Base

  # Validations
  validates_presence_of :title, :breadcrumb, :status_id, :message => 'required'  
  validates_presence_of :slug, :if => Proc.new {|p| p.ancestry.present?}
  validates_length_of :title, :maximum => 255, :message => '%d-character limit'
  validates_length_of :slug, :maximum => 100, :message => '%d-character limit'
  #validates_length_of :breadcrumb, :maximum => 160, :message => '%d-character limit'
  validates_format_of :slug, :with => %r{^([-_.A-Za-z0-9]*|/)$}, :message => 'invalid format'  
  validates_uniqueness_of :slug, :scope => :ancestry, :message => 'slug already in use for child of parent'
  
  has_one :node_content, :dependent => :destroy
  accepts_nested_attributes_for :node_content
  
  belongs_to :snippet
  belongs_to :created_by, :class_name => 'User'
  belongs_to :updated_by, :class_name => 'User'
  
  acts_as_activity :user
    
  @@status = {
    'draft' => 1,
    'published' => 2,
    1 => 'draft',
    2 => 'published',
    :draft => 1,
    :published => 2
  }
  cattr_accessor :status
  attr_accessor :save_and_publish, :unpublish, :show_draft, :order, :trash
  
  # Callbacks
  after_initialize :set_status
  
  before_save :rebuild_path
  before_save :update_published_at<commit_msg>breadcrumb<commit_after>class Node < ActiveRecord::Base

  # Validations
  validates_presence_of :title, :status_id, :message => 'required'  
  validates_presence_of :slug, :if => Proc.new {|p| p.ancestry.present?}
  validates_length_of :title, :maximum => 255, :message => '%d-character limit'
  validates_length_of :slug, :maximum => 100, :message => '%d-character limit'
  validates_format_of :slug, :with => %r{^([-_.A-Za-z0-9]*|/)$}, :message => 'invalid format'  
  validates_uniqueness_of :slug, :scope => :ancestry, :message => 'slug already in use for child of parent'
  
  has_one :node_content, :dependent => :destroy
  accepts_nested_attributes_for :node_content
  
  belongs_to :snippet
  belongs_to :created_by, :class_name => 'User'
  belongs_to :updated_by, :class_name => 'User'
  
  acts_as_activity :user
    
  @@status = {
    'draft' => 1,
    'published' => 2,
    1 => 'draft',
    2 => 'published',
    :draft => 1,
    :published => 2
  }
  cattr_accessor :status
  attr_accessor :save_and_publish, :unpublish, :show_draft, :order, :trash
  
  # Callbacks
  after_initialize :set_status
  
  before_save :rebuild_path
  before_save :update_published_at
{'fraction_non_alphanumeric': 0.13995117982099267, 'fraction_numerical': 0.012611879576891782, 'mean_word_length': 4.392543859649122, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '2444473', 'n_tokens_mistral': 908, 'n_tokens_neox': 885, 'n_words': 197}