<commit_before>class DirectMessage < ApplicationRecord
  belongs_to :sender,   class_name: "User", inverse_of: :direct_messages_sent
  belongs_to :receiver, class_name: "User", inverse_of: :direct_messages_received

  validates :title,    presence: true
  validates :body,     presence: true
  validates :sender,   presence: true
  validates :receiver, presence: true
  validate  :max_per_day

  scope :today, lambda { where(created_at: Date.current.beginning_of_day..Date.current.end_of_day) }

  def max_per_day
    return if errors.any?

    max = Setting[:direct_message_max_per_day]
    return unless max

    if sender.direct_messages_sent.today.count >= max.to_i
      errors.add(:title, I18n.t("activerecord.errors.models.direct_message.attributes.max_per_day.invalid"))
    end
  end
end<commit_msg>Use `Date#all_day` in `DirectMessage.today`<commit_after>class DirectMessage < ApplicationRecord
  belongs_to :sender,   class_name: "User", inverse_of: :direct_messages_sent
  belongs_to :receiver, class_name: "User", inverse_of: :direct_messages_received

  validates :title,    presence: true
  validates :body,     presence: true
  validates :sender,   presence: true
  validates :receiver, presence: true
  validate  :max_per_day

  scope :today, lambda { where(created_at: Date.current.all_day) }

  def max_per_day
    return if errors.any?

    max = Setting[:direct_message_max_per_day]
    return unless max

    if sender.direct_messages_sent.today.count >= max.to_i
      errors.add(:title, I18n.t("activerecord.errors.models.direct_message.attributes.max_per_day.invalid"))
    end
  end
end
{'fraction_non_alphanumeric': 0.09305210918114144, 'fraction_numerical': 0.0024813895781637717, 'mean_word_length': 4.659649122807018, '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': '6410052', 'n_tokens_mistral': 537, 'n_tokens_neox': 523, 'n_words': 114}