<commit_before>class PlayerSelection < ApplicationRecord
  belongs_to :player_hero
  belongs_to :composition
  belongs_to :map_segment

  validates :player_hero, :composition, :map_segment, presence: true
  validates :player_hero_id,
    uniqueness: { scope: [:composition_id, :map_segment_id] }
end<commit_msg>Validate map_segment and comp map agree<commit_after>class PlayerSelection < ApplicationRecord
  belongs_to :player_hero
  belongs_to :composition
  belongs_to :map_segment

  validates :player_hero, :composition, :map_segment, presence: true
  validates :player_hero_id,
    uniqueness: { scope: [:composition_id, :map_segment_id] }
  validate :map_segment_matches_composition_map

  private

  def map_segment_matches_composition_map
    return unless map_segment && composition

    unless map_segment.map == composition.map
      errors.add(:map_segment, 'must match the composition map.')
    end
  end
end
{'fraction_non_alphanumeric': 0.07049891540130152, 'fraction_numerical': 0.0, 'mean_word_length': 5.640287769784172, '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': '4126545', 'n_tokens_mistral': 282, 'n_tokens_neox': 277, 'n_words': 68}