<commit_before>module Hicube
  class Page
  
    include Mongoid::Document
    include Mongoid::Timestamps
    include Mongoid::Slug

    #
    # Slugs
    #
    slug              :title

    #
    #
    #
    has_many :children, class_name: 'Hicube::Page'
    belongs_to :parent, class_name: 'Hicube::Page'

    field :tt, type: String,
      as:             :title

    field :bd, type: String,
      as:             :body

    # field :jt, type: Boolean, # Saving as String, so don't have to do transalation from String to Boolean in controller
    #   as:             :junction,
    #   default:        false

    # SEO settings

    # Validations
    validates_presence_of :title

    #
    # Scopes
    #
    # default_scope -> { asc(:parent) }
    scope :parents, -> { where(parent: nil) }

    def junction?
      !(self.children.nil? or self.children.empty?)
    end

    def child?
      !self.parent.nil?
    end
  end
end<commit_msg>Fix- identify child pages correctly<commit_after>module Hicube
  class Page
  
    include Mongoid::Document
    include Mongoid::Timestamps
    include Mongoid::Slug

    #
    # Slugs
    #
    slug              :title

    #
    #
    #
    has_many :children, class_name: 'Hicube::Page'
    belongs_to :parent, class_name: 'Hicube::Page'

    field :tt, type: String,
      as:             :title

    field :bd, type: String,
      as:             :body

    # field :jt, type: Boolean, # Saving as String, so don't have to do transalation from String to Boolean in controller
    #   as:             :junction,
    #   default:        false

    # SEO settings

    # Validations
    validates_presence_of :title

    #
    # Scopes
    #
    # default_scope -> { asc(:parent) }
    scope :parents, -> { where(parent: nil) }

    def junction?
      !(self.children.nil? or self.children.empty?)
    end

    def child?
      !self.parent.nil? and self.parent.exists?
    end
  end
end
{'fraction_non_alphanumeric': 0.09917355371900827, 'fraction_numerical': 0.0, 'mean_word_length': 1.9259818731117824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7287289', 'n_tokens_mistral': 635, 'n_tokens_neox': 608, 'n_words': 165}