<commit_before>class Question < Prequel::Record
  column :id, :integer
  column :organization_id, :integer
  column :creator_id, :integer
  column :body, :string
  column :details, :string
  column :vote_count, :integer, :default => 0
  column :score, :float
  column :created_at, :datetime
  column :updated_at, :datetime

  has_many :answers
  has_many :votes
  has_many :rankings
  has_many :majorities

  belongs_to :creator, :class_name => "User"

  def can_update_or_destroy?
    creator_id == current_user.id
  end
  alias can_update? can_update_or_destroy?
  alias can_destroy? can_update_or_destroy?

  def create_whitelist
    [:body, :details]
  end

  def update_whitelist
    [:body, :details]
  end

  def before_create
    ensure_body_within_limit
    self.creator ||= current_user
  end

  def ensure_body_within_limit
    raise SecurityError, "Body exceeds 140 characters" if body.length > 140
  end

  def before_update(changeset)
    ensure_body_within_limit if changeset[:body]
  end

  def before_destroy
    answers.each(&:destroy)<commit_msg>Questions must have a body<commit_after>class Question < Prequel::Record
  column :id, :integer
  column :organization_id, :integer
  column :creator_id, :integer
  column :body, :string
  column :details, :string
  column :vote_count, :integer, :default => 0
  column :score, :float
  column :created_at, :datetime
  column :updated_at, :datetime

  has_many :answers
  has_many :votes
  has_many :rankings
  has_many :majorities

  belongs_to :creator, :class_name => "User"

  validates_presence_of :body

  def can_update_or_destroy?
    creator_id == current_user.id
  end
  alias can_update? can_update_or_destroy?
  alias can_destroy? can_update_or_destroy?

  def create_whitelist
    [:body, :details]
  end

  def update_whitelist
    [:body, :details]
  end

  def before_create
    ensure_body_within_limit
    self.creator ||= current_user
  end

  def ensure_body_within_limit
    raise SecurityError, "Body exceeds 140 characters" if body.length > 140
  end

  def before_update(changeset)
    ensure_body_within_limit if changeset[:body]
  end

  def before_destroy
    answers.each(&:destroy)
{'fraction_non_alphanumeric': 0.07865685372585096, 'fraction_numerical': 0.006439742410303588, 'mean_word_length': 4.304878048780488, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1268468', 'n_tokens_mistral': 764, 'n_tokens_neox': 718, 'n_words': 189}