<commit_before># encoding: UTF-8
# == Schema Information
#
# Table name: wiki_pages
#
#  id          :integer          not null, primary key
#  title       :string(100)      not null
#  cached_slug :string(105)
#  body        :text(4294967295)
#  created_at  :datetime
#  updated_at  :datetime
#

#
# The wiki have pages, with the content that can't go anywhere else.
#
class WikiPage < Content
  self.table_name = "wiki_pages"
  self.type = "Page wiki"

  RESERVED_WORDS = %w(index nouveau modifications pages)
  has_many :versions,
    -> { order(version: :desc) },
    class_name: "WikiVersion",
    dependent: :destroy,
    inverse_of: :wiki_page
  reserved = RESERVED_WORDS + RESERVED_WORDS.map(&:capitalize) + RESERVED_WORDS.map(&:upcase)
  validates :title, presence: { message: "Le titre est obligatoire" },
                    length: { maximum: 100, message: "Le titre est trop long" },
                    exclusion: { in: reserved, message: "Ce titre est réservé pour une page spéciale" }
  validates :body,  presence: { message: "Le corps est obligatoire" }

### SEO ###

  extend FriendlyId
  friendly_id :title, reserved_words: RESERVED_WORDS

### Hey, it's a wiki! ###

  attr_accessor :wiki_body, :message, :user_id

  wikify_attr :body

  after_save :create_new_version<commit_msg>WikiPage: add automatic value on save for the new column truncated_body<commit_after># encoding: UTF-8
# == Schema Information
#
# Table name: wiki_pages
#
#  id          :integer          not null, primary key
#  title       :string(100)      not null
#  cached_slug :string(105)
#  body        :text(4294967295)
#  created_at  :datetime
#  updated_at  :datetime
#

#
# The wiki have pages, with the content that can't go anywhere else.
#
class WikiPage < Content
  self.table_name = "wiki_pages"
  self.type = "Page wiki"

  RESERVED_WORDS = %w(index nouveau modifications pages)
  has_many :versions,
    -> { order(version: :desc) },
    class_name: "WikiVersion",
    dependent: :destroy,
    inverse_of: :wiki_page
  reserved = RESERVED_WORDS + RESERVED_WORDS.map(&:capitalize) + RESERVED_WORDS.map(&:upcase)
  validates :title, presence: { message: "Le titre est obligatoire" },
                    length: { maximum: 100, message: "Le titre est trop long" },
                    exclusion: { in: reserved, message: "Ce titre est réservé pour une page spéciale" }
  validates :body,  presence: { message: "Le corps est obligatoire" }

### SEO ###

  extend FriendlyId
  friendly_id :title, reserved_words: RESERVED_WORDS

### Hey, it's a wiki! ###

  attr_accessor :wiki_body, :message, :user_id

  wikify_attr :body
  truncate_attr :body

  after_save :create_new_version
{'fraction_non_alphanumeric': 0.10828976848394324, 'fraction_numerical': 0.014936519790888723, 'mean_word_length': 3.399014778325123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7212503', 'n_tokens_mistral': 929, 'n_tokens_neox': 881, 'n_words': 253}