<commit_before>module Spree
  class AlsoBought < ActiveRecord::Base
    belongs_to :product1, class_name: 'Spree::Product'
    belongs_to :product2, class_name: 'Spree::Product'
  end
end<commit_msg>Update all also_bougth combinations count * Create mehtod on AlsoBought<commit_after>module Spree
  class AlsoBought < ActiveRecord::Base
    belongs_to :product1, class_name: 'Spree::Product'
    belongs_to :product2, class_name: 'Spree::Product'

    def self.update(products)
      products.combination(2).each do |product1,product2|
        also = Spree::AlsoBought.where("product1_id IN (?) AND product2_id IN (?)", [product1.id,product2.id], [product1.id,product2.id]).first
        also ? also.increment!(:count) : Spree::AlsoBought.create(product1: product1, product2: product2)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11439114391143912, 'fraction_numerical': 0.020910209102091022, 'mean_word_length': 4.898550724637682, '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': '2466333', 'n_tokens_mistral': 271, 'n_tokens_neox': 270, 'n_words': 58}