<commit_before>Spree::Product.class_eval do
  attr_accessible :tire_speed_code_id, :tire_rf, :tire_innertube_id, :tire_width_id,
                  :tire_serial_id, :tire_gr, :tire_season
  attr_accessible :count_on_hand, :price_in_offert, :show_in_offert

  delegate_belongs_to :master, :tire_width_id, :tire_rf, :tire_innertube_id,
                    :tire_speed_code_id, :tire_serial_id, :tire_gr, :tire_season, :price_in_offert

  scope :by_width, lambda { |width| joins(:master).where("spree_variants.tire_width_id = ?", width)}
  scope :by_serial, lambda { |serial| joins(:master).where("spree_variants.tire_serial_id = ?", serial)}
  scope :by_innertube, lambda { |innertube| joins(:master).where("spree_variants.tire_innertube_id = ?", innertube)}
  scope :by_gr, lambda { |gr| joins(:master).where("spree_variants.tire_gr = ?", gr) }
  scope :by_speed, lambda { |speed| joins(:master).where("spree_variants.tire_speed_code_id = ?", speed)}
  scope :by_rf, lambda { |rf| joins(:master).where("spree_variants.tire_rf = ?", rf)}
  scope :by_season, lambda { |season| joins(:master).where("spree_variants.tire_season = ?", season)}
  scope :in_offert, lambda { |offert| joins(:master).where(:show_in_offert =>  offert)}
  scope :by_supplier, lambda { |supplier| joins(:master).where(:supplier_id =>  supplier)}

  def display_price_in_offert
    Spree::Money.new(price_in_offert).to_s
  end

  def calculate_tires(id)
    variante = Spree::Variant.find_by_product_id(id)
    ancho = variante.tire_width.name
    perfil = variante.tire_serial.name
    llanta = variante.tire_innertube.name
    vel = variante.tire_speed_code.name
    a = ancho.nil? ? "*" : ancho
    p = perfil.nil? ? "*" : perfil
    l = llanta.nil? ? "*" : llanta
    v = vel.nil? ? "*" : vel
    return a + "/" + p + " " + l + v
  end
end<commit_msg>Mas mejoras<commit_after>Spree::Product.class_eval do
  attr_accessible :tire_speed_code_id, :tire_rf, :tire_innertube_id, :tire_width_id,
                  :tire_serial_id, :tire_gr, :tire_season
  attr_accessible :count_on_hand, :price_in_offert, :show_in_offert

  delegate_belongs_to :master, :tire_width_id, :tire_rf, :tire_innertube_id,
                    :tire_speed_code_id, :tire_serial_id, :tire_gr, :tire_season, :price_in_offert

  scope :by_width, lambda { |width| joins(:master).where("spree_variants.tire_width_id = ?", width)}
  scope :by_serial, lambda { |serial| joins(:master).where("spree_variants.tire_serial_id = ?", serial)}
  scope :by_innertube, lambda { |innertube| joins(:master).where("spree_variants.tire_innertube_id = ?", innertube)}
  scope :by_gr, lambda { |gr| joins(:master).where("spree_variants.tire_gr = ?", gr) }
  scope :by_speed, lambda { |speed| joins(:master).where("spree_variants.tire_speed_code_id = ?", speed)}
  scope :by_rf, lambda { |rf| joins(:master).where("spree_variants.tire_rf = ?", rf)}
  scope :by_season, lambda { |season| joins(:master).where("spree_variants.tire_season = ?", season)}
  scope :in_offert, lambda { |offert| joins(:master).where(:show_in_offert =>  offert)}
  scope :by_supplier, lambda { |supplier| joins(:master).where(:supplier_id =>  supplier)}

  def display_price_in_offert
    Spree::Money.new(price_in_offert).to_s
  end

  def calculate_tires(id)
    variante = Spree::Variant.find_by_product_id(id)
    ancho = variante.tire_width.name
    perfil = variante.tire_serial.name
    llanta = variante.tire_innertube.name
    vel = variante.tire_speed_code.name
    a = ancho.nil? ? "*" : ancho
    p = perfil.nil? ? "*" : perfil
    l = llanta.nil? ? "*" : llanta
    v = vel.nil? ? "*" : vel
    return a + "/" + p + " " + l + v
  end

  def full_name(id)
    product.name + "\n" + product.calculate_tires(id)
  end

end
{'fraction_non_alphanumeric': 0.14511802575107297, 'fraction_numerical': 0.0, 'mean_word_length': 4.624434389140271, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1186154', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1433, 'n_words': 232}