<commit_before>Spree::Product.class_eval do

  def try_variant(option_values)
    return master if options.blank?
    new_variant = Spree::Variant.new(product: self,
                                     sku: "-#{(Time.now.to_f * 1000.0).to_i}",
                                     track_inventory: false)
    new_variant.add_options_and_calc_price option_values
    return get_or_save_variant new_variant
  end


  private

  def get_or_save_variant(new_variant)
    aspirants = Spree::Variant.includes(:option_values).where(is_master: false,
                                                              product: self,
                                                              deleted_at: nil)
    similar = aspirants.detect { |av| new_variant.similar? av }
    return similar if similar.present?

    new_variant.save!
    return new_variant
  end<commit_msg>bugfix, prefix new sku<commit_after>Spree::Product.class_eval do

  def try_variant(option_values)
    return master if options.blank?
    new_variant = Spree::Variant.new(product: self,
                                     sku: "#{self.sku}-#{(Time.now.to_f * 1000.0).to_i}",
                                     track_inventory: false)
    new_variant.add_options_and_calc_price option_values
    return get_or_save_variant new_variant
  end


  private

  def get_or_save_variant(new_variant)
    aspirants = Spree::Variant.includes(:option_values).where(is_master: false,
                                                              product: self,
                                                              deleted_at: nil)
    similar = aspirants.detect { |av| new_variant.similar? av }
    return similar if similar.present?

    new_variant.save!
    return new_variant
  end
{'fraction_non_alphanumeric': 0.07591324200913242, 'fraction_numerical': 0.005707762557077625, 'mean_word_length': 1.7693522906793049, 'pattern_counts': {'":': 0, '<': 3, '<?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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3936632', 'n_tokens_mistral': 483, 'n_tokens_neox': 460, 'n_words': 92}