<commit_before>module Spree
  class StockLocation < ActiveRecord::Base
    has_many :stock_items, dependent: :destroy
    has_many :stock_movements, through: :stock_items

    belongs_to :state
    belongs_to :country

    validates_presence_of :name

    attr_accessible :name, :active, :address1, :address2, :city, :zipcode,
                    :state_name, :state_id, :country_id, :phone

    scope :active, -> { where(active: true) }

    after_create :create_stock_items

    def stock_item(variant)
      stock_items.where(variant_id: variant).first<commit_msg>Create Stock Items when Stock Location is created<commit_after>module Spree
  class StockLocation < ActiveRecord::Base
    has_many :stock_items, dependent: :destroy
    has_many :stock_movements, through: :stock_items

    belongs_to :state
    belongs_to :country

    validates_presence_of :name

    attr_accessible :name, :active, :address1, :address2, :city, :zipcode,
                    :state_name, :state_id, :country_id, :phone

    scope :active, -> { where(active: true) }

    after_create :create_stock_items

    after_create :populate_stock_items

    def stock_item(variant)
      stock_items.where(variant_id: variant).first
{'fraction_non_alphanumeric': 0.0884297520661157, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 3.902834008097166, 'pattern_counts': {'":': 0, '<': 5, '<?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': '511831', 'n_tokens_mistral': 382, 'n_tokens_neox': 367, 'n_words': 88}