<commit_before>module Tree
  def descendants
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/descendants") do
      children_to_be_processed = [self]
      all_children = Array.new
      while !children_to_be_processed.empty?
        child = children_to_be_processed.shift
        all_children.push child.id.to_i
        children_to_be_processed.concat(child.children)
      end
      all_children
    end
  end

  def full_lineage(size = nil)
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/full_lineage") do
      if (size==nil)
        lineage = (ancestors.reverse << self).collect{|e| e.title }
      else 
        lineage = (ancestors.reverse << self).collect do |e| 
          title = e.title
          chars = title.mb_chars
          chars.size>size ? "#{chars[0...size].to_s}..." : title
        end
      end
      lineage.join(' > ')
    end
  end
  
  def count_inherited_media(type = nil)
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/count_inherited_media") { CachedCategoryCount.updated_count(self.id.to_i, type).count }
  end

  def permalink
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/permalink") do
      association = registered_theme_association<commit_msg>expiring cache<commit_after>module Tree
  def descendants
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/descendants", :expires_in => 1.day) do
      children_to_be_processed = [self]
      all_children = Array.new
      while !children_to_be_processed.empty?
        child = children_to_be_processed.shift
        all_children.push child.id.to_i
        children_to_be_processed.concat(child.children)
      end
      all_children
    end
  end

  def full_lineage(size = nil)
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/full_lineage", :expires_in => 1.day) do
      if (size==nil)
        lineage = (ancestors.reverse << self).collect{|e| e.title }
      else 
        lineage = (ancestors.reverse << self).collect do |e| 
          title = e.title
          chars = title.mb_chars
          chars.size>size ? "#{chars[0...size].to_s}..." : title
        end
      end
      lineage.join(' > ')
    end
  end
  
  def count_inherited_media(type = nil)
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/count_inherited_media", :expires_in => 1.day) { CachedCategoryCount.updated_count(self.id.to_i, type).count }
  end

  def permalink
    Rails.cache.fetch("#{self.class.element_name}-#{self.id}/permalink", :expires_in => 1.day) do
      association = registered_theme_association
{'fraction_non_alphanumeric': 0.1304178055447091, 'fraction_numerical': 0.0023428348301444747, 'mean_word_length': 2.893617021276596, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3890507', 'n_tokens_mistral': 877, 'n_tokens_neox': 856, 'n_words': 134}