<commit_before>class Imports::Assessment < CacheDependendRecord
  belongs_to :configuration, class_name: 'Imports::Configuration', inverse_of: :assessments
  belongs_to :assessment, class_name: '::Assessment', inverse_of: :imports_assessment
  validates :gender, :discipline, :configuration, :foreign_key, presence: true

  before_create do
    self.assessment = possible_assessments.first
  end

  def discipline_model
    ::Discipline.for_key(discipline)
  end

  def possible_assessments
    ::Assessment.discipline(discipline_model).gender(gender)
  end
end<commit_msg>Vorauswahl beim Import verbessern<commit_after>class Imports::Assessment < CacheDependendRecord
  belongs_to :configuration, class_name: 'Imports::Configuration', inverse_of: :assessments
  belongs_to :assessment, class_name: '::Assessment', inverse_of: :imports_assessment
  validates :gender, :discipline, :configuration, :foreign_key, presence: true

  before_create do
    self.assessment = possible_assessments.find { |pa| pa.decorate.to_s == decorate.to_s } || possible_assessments.first
  end

  def discipline_model
    ::Discipline.for_key(discipline)
  end

  def possible_assessments
    ::Assessment.discipline(discipline_model).gender(gender)
  end
end
{'fraction_non_alphanumeric': 0.09208400646203554, 'fraction_numerical': 0.0, 'mean_word_length': 6.463855421686747, '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': '5264018', 'n_tokens_mistral': 397, 'n_tokens_neox': 384, 'n_words': 78}