<commit_before>require 'noodall/articles/categories'

class Article < Noodall::Node
  extend Noodall::Articles::Categories

  delegate :list, :articles, :all_categories, :recent_articles, :archive, :to => :parent

  key :categories, Array, :index => true

  key :asset_id, ObjectId
  belongs_to :asset

  def category_list=(string)
    self.categories = string.to_s.split(',').map{ |t| t.strip.titlecase }.reject(&:blank?).compact.uniq
  end

  def category_list
    categories.join(',')
  end

  private

  # Always put a new article at the top of a list
  def set_position
    write_attribute :position, 0 if self.position.blank?<commit_msg>Adding date to permalink slug<commit_after>require 'noodall/articles/categories'

class Article < Noodall::Node
  extend Noodall::Articles::Categories

  delegate :list, :articles, :all_categories, :recent_articles, :archive, :to => :parent

  key :categories, Array, :index => true

  key :asset_id, ObjectId
  belongs_to :asset

  def category_list=(string)
    self.categories = string.to_s.split(',').map{ |t| t.strip.titlecase }.reject(&:blank?).compact.uniq
  end

  def category_list
    categories.join(',')
  end

  protected

  # A slug for creating the permalink with date
  def slug
    (published_at || current_time).strftime('%Y/%m/%d/') + super
  end

  private

  # Always put a new article at the top of a list
  def set_position
    write_attribute :position, 0 if self.position.blank?
{'fraction_non_alphanumeric': 0.11687413554633472, 'fraction_numerical': 0.0013831258644536654, 'mean_word_length': 4.223826714801444, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7619868', 'n_tokens_mistral': 493, 'n_tokens_neox': 457, 'n_words': 130}