<commit_before>class ProductSibling < ActiveRecord::Base
  belongs_to :product
  def self.get_relations
    siblings_activerecords = []
    siblings_unchanged = []
    TextSpec.joins("INNER JOIN `cat_specs` ON `text_specs`.product_id = `cat_specs`.product_id").where(cat_specs: {name: "product_type",value: Session.product_type_leaves}, text_specs: {name: "relations"}).each do |record|
      data = JSON.parse(record.value.gsub("=>",":"))
      if data && !data.empty?
        p_id = record.product_id
        skus = []
        data.each{|sk| skus<<sk["sku"] if sk["type"]=="Variant"} # AdditionalMedia -- has the other image urls. Save these other small image urls instead of colors.
        #Check if the product is in our database
        sibs = skus.map{|sku|Product.find_by_sku_and_retailer(sku, Session.retailer).try(:id)}.compact
        sibs.each do |sib_id|
          ps = ProductSibling.find_or_initialize_by_product_id(p_id)
          if ps.sibling_id != sib_id
            ps.sibling_id = sib_id
            ps.name = "color"
            ps.value = CatSpec.find_by_product_id_and_name(sib_id,"color").try(:value)<commit_msg>makins sure that bundles are only siblinbgs with other bundles and non-bundles are siblings with non-bundles<commit_after>class ProductSibling < ActiveRecord::Base
  belongs_to :product
  def self.get_relations
    siblings_activerecords = []
    siblings_unchanged = []
    TextSpec.joins("INNER JOIN `cat_specs` ON `text_specs`.product_id = `cat_specs`.product_id").where(cat_specs: {name: "product_type",value: Session.product_type_leaves}, text_specs: {name: "relations"}).each do |record|
      data = JSON.parse(record.value.gsub("=>",":"))
      if data && !data.empty?
        p_id = record.product_id
        skus = []
        isB = BinSpec.find_by_product_id_and_name(p_id, 'isBundle')
        data.each{|sk| skus<<sk["sku"] if sk["type"]=="Variant" && (!isB || sk["sku"].match('B') && (!sk["sku"].match('B') || isB))} # AdditionalMedia -- has the other image urls. Save these other small image urls instead of colors.
        #Check if the product is in our database
        sibs = skus.map{|sku|Product.find_by_sku_and_retailer(sku, Session.retailer).try(:id)}.compact
        sibs.each do |sib_id|
          ps = ProductSibling.find_or_initialize_by_product_id(p_id)
          if ps.sibling_id != sib_id
            ps.sibling_id = sib_id
            ps.name = "color"
            ps.value = CatSpec.find_by_product_id_and_name(sib_id,"color").try(:value)
{'fraction_non_alphanumeric': 0.13213572854291417, 'fraction_numerical': 0.0, 'mean_word_length': 3.5480943738656987, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 5, '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': '3924426', 'n_tokens_mistral': 861, 'n_tokens_neox': 860, 'n_words': 171}