<commit_before>class Chat < ActiveRecord::Base
  has_many :feedbacks
  validates_presence_of :student_id, :native_speaker_id
  belongs_to :student, class_name: "User"
  belongs_to :native_speaker, class_name: "User"
  belongs_to :topic
  belongs_to :chat_room

  def language
    self.topic.language
  end

  def level
    self.topic.level
  end
end<commit_msg>Add model helper to create the two chats needed for a chat room<commit_after>class Chat < ActiveRecord::Base
  has_many :feedbacks
  validates_presence_of :student_id, :native_speaker_id
  belongs_to :student, class_name: "User"
  belongs_to :native_speaker, class_name: "User"
  belongs_to :topic
  belongs_to :chat_room

  def language
    self.topic.language
  end

  def level
    self.topic.level
  end

  def self.build_chats_pair(invitation, room)
    [ self.create(student: invitation.recipient, native_speaker: invitation.sender,
                  topic: Invitation.generate_random_topic(invitation.recipient),
                  chat_room: room),
    self.create(student: invitation.sender, native_speaker: invitation.recipient,
                  topic: Invitation.generate_random_topic(invitation.sender),
                  chat_room: room) ]
  end
end
{'fraction_non_alphanumeric': 0.07440719542109567, 'fraction_numerical': 0.0, 'mean_word_length': 3.762645914396887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5678129', 'n_tokens_mistral': 391, 'n_tokens_neox': 386, 'n_words': 89}