<commit_before>require 'pp'

Product.class_eval do

  def option_values
    option_types.map{|i| i.option_values }.flatten.uniq
  end
  
  def grouped_option_values
    option_values.group_by(&:option_type)
  end
  
  def variant_options_hash  
    return @variant_options_hash if @variant_options_hash
    @variant_options_hash = Hash[grouped_option_values.map{ |type, values| 
      [type.id.inspect, Hash[values.map{ |value|         
        [value.id.inspect, Hash[variants.includes(:option_values).select{ |variant| 
          variant.option_values.select{ |val| 
            val.id == value.id && val.option_type_id == type.id 
          }.length == 1 }.map{ |v| [ v.id, { :id => v.id, :count => v.count_on_hand, :price => v.price } ] }]
        ]
      }]]
    }]
    pp @variant_options_hash
    @variant_options_hash
  end
  
end<commit_msg>removed pp from product decorator<commit_after>Product.class_eval do

  def option_values
    option_types.map{|i| i.option_values }.flatten.uniq
  end
  
  def grouped_option_values
    option_values.group_by(&:option_type)
  end
  
  def variant_options_hash  
    return @variant_options_hash if @variant_options_hash
    @variant_options_hash = Hash[grouped_option_values.map{ |type, values| 
      [type.id.inspect, Hash[values.map{ |value|         
        [value.id.inspect, Hash[variants.includes(:option_values).select{ |variant| 
          variant.option_values.select{ |val| 
            val.id == value.id && val.option_type_id == type.id 
          }.length == 1 }.map{ |v| [ v.id, { :id => v.id, :count => v.count_on_hand, :price => v.price } ] }]
        ]
      }]]
    }]
    @variant_options_hash
  end
  
end
{'fraction_non_alphanumeric': 0.12343470483005367, 'fraction_numerical': 0.0011926058437686344, 'mean_word_length': 2.866359447004608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2112005', 'n_tokens_mistral': 595, 'n_tokens_neox': 575, 'n_words': 103}