<commit_before>class Question
  include Mongoid::Document
  include Mongoid::Timestamps

  include MongoidExt::Filter
  include MongoidExt::Slugizer
  include MongoidExt::Tags
  include Support::Versionable
  include Support::Voteable
  include Shapado::Models::GeoCommon

  index :tags

  identity :type => String

  field :title, :type => String, :default => ""
  field :body, :type => String
  slug_key :title, :unique => true, :min_length => 8
  field :slugs, :type => Array
  index :slugs

  field :answers_count, :type => Integer, :default => 0
  field :views_count, :type => Integer, :default => 0
  field :hotness, :type => Integer, :default => 0
  field :flags_count, :type => Integer, :default => 0
  field :close_requests_count, :type => Integer, :default => 0
  field :open_requests_count, :type => Integer, :default => 0
  field :favorites_count, :type => Integer, :default => 0

  field :adult_content, :type => Boolean, :default => false
  field :banned, :type => Boolean, :default => false
  index :banned
  field :accepted, :type => Boolean, :default => false
  field :closed, :type => Boolean, :default => false
  field :closed_at, :type => Time

  field :anonymous, :type => Boolean, :default => false
  index :anonymous

  field :answered_with_id, :type => String
  referenced_in :answered_with, :class_name => "Answer"

  field :wiki, :type => Boolean, :default => false
  field :language, :type => String, :default => "en"
  index :language

  field :activity_at, :type => Time

  referenced_in :user
  index :user_id

  field :answer_id, :type => String
  referenced_in :answer

  referenced_in :group
  index :group_id


  field :watchers, :type => Array, :default => []
  field :followers_count, :type => Integer, :default => 0
  references_many :followers, :stored_as => :array, :inverse_of => :question, :class_name => "User"#, :foreign_key => :watchers FIXME mongoid

  field :updated_by_id, :type => String
  referenced_in :updated_by, :class_name => "User"

  field :close_reason_id, :type => String

  field :last_target_type, :type => String
  field :last_target_id, :type => String
  field :last_target_date, :type => Time

#   referenced_in :last_target, :polymorphic => true

  key :last_target_user_id, String
  referenced_in :last_target_user, :class_name => "User"

  references_many :answers, :dependent => :destroy
  references_many :badges, :as => "source"

  embeds_many :comments, :as => "commentable", :order => "created_at asc"
  embeds_many :flags
  embeds_many :close_requests
  embeds_many :open_requests

  validates_presence_of :title
  validates_presence_of :user
  validates_uniqueness_of :slug, :scope => :group_id, :allow_blank => true

  validates_length_of       :title,    :in => 5..100, :message => lambda { I18n.t("questions.model.messages.title_too_long") }
  validates_length_of       :body,     :minimum => 5, :allow_blank => true, :allow_nil => true, :if => lambda { |q| !q.disable_limits? }

#  FIXME mongoid (create a validator for tags size)
#   validates_true_for :tags, :logic => lambda { |q| q.tags.size <= 9},
#                      :message => lambda { |q| I18n.t("questions.model.messages.too_many_tags") if q.tags.size > 9 }

  versionable_keys :title, :body, :tags
  filterable_keys :title, :body
  language :language<commit_msg>fix field definition<commit_after>class Question
  include Mongoid::Document
  include Mongoid::Timestamps

  include MongoidExt::Filter
  include MongoidExt::Slugizer
  include MongoidExt::Tags
  include Support::Versionable
  include Support::Voteable
  include Shapado::Models::GeoCommon

  index :tags

  identity :type => String

  field :title, :type => String, :default => ""
  field :body, :type => String
  slug_key :title, :unique => true, :min_length => 8
  field :slugs, :type => Array
  index :slugs

  field :answers_count, :type => Integer, :default => 0
  field :views_count, :type => Integer, :default => 0
  field :hotness, :type => Integer, :default => 0
  field :flags_count, :type => Integer, :default => 0
  field :close_requests_count, :type => Integer, :default => 0
  field :open_requests_count, :type => Integer, :default => 0
  field :favorites_count, :type => Integer, :default => 0

  field :adult_content, :type => Boolean, :default => false
  field :banned, :type => Boolean, :default => false
  index :banned
  field :accepted, :type => Boolean, :default => false
  field :closed, :type => Boolean, :default => false
  field :closed_at, :type => Time

  field :anonymous, :type => Boolean, :default => false
  index :anonymous

  field :answered_with_id, :type => String
  referenced_in :answered_with, :class_name => "Answer"

  field :wiki, :type => Boolean, :default => false
  field :language, :type => String, :default => "en"
  index :language

  field :activity_at, :type => Time

  referenced_in :user
  index :user_id

  field :answer_id, :type => String
  referenced_in :answer

  referenced_in :group
  index :group_id


  field :watchers, :type => Array, :default => []
  field :followers_count, :type => Integer, :default => 0
  references_many :followers, :stored_as => :array, :inverse_of => :question, :class_name => "User"#, :foreign_key => :watchers FIXME mongoid

  field :updated_by_id, :type => String
  referenced_in :updated_by, :class_name => "User"

  field :close_reason_id, :type => String

  field :last_target_type, :type => String
  field :last_target_id, :type => String
  field :last_target_date, :type => Time

#   referenced_in :last_target, :polymorphic => true

  field :last_target_user_id, :type => String
  referenced_in :last_target_user, :class_name => "User"

  references_many :answers, :dependent => :destroy
  references_many :badges, :as => "source"

  embeds_many :comments, :as => "commentable", :order => "created_at asc"
  embeds_many :flags
  embeds_many :close_requests
  embeds_many :open_requests

  validates_presence_of :title
  validates_presence_of :user
  validates_uniqueness_of :slug, :scope => :group_id, :allow_blank => true

  validates_length_of       :title,    :in => 5..100, :message => lambda { I18n.t("questions.model.messages.title_too_long") }
  validates_length_of       :body,     :minimum => 5, :allow_blank => true, :allow_nil => true, :if => lambda { |q| !q.disable_limits? }

#  FIXME mongoid (create a validator for tags size)
#   validates_true_for :tags, :logic => lambda { |q| q.tags.size <= 9},
#                      :message => lambda { |q| I18n.t("questions.model.messages.too_many_tags") if q.tags.size > 9 }

  versionable_keys :title, :body, :tags
  filterable_keys :title, :body
  language :language
{'fraction_non_alphanumeric': 0.13360507246376813, 'fraction_numerical': 0.006038647342995169, 'mean_word_length': 4.434782608695652, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 146, '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': '2811547', 'n_tokens_mistral': 2264, 'n_tokens_neox': 2159, 'n_words': 608}