<commit_before>Spree::ShippingMethod.class_eval do
  acts_as_taggable

  has_many :distributor_shipping_methods
  has_many :distributors, through: :distributor_shipping_methods, class_name: 'Enterprise', foreign_key: 'distributor_id'

  after_save :touch_distributors
  attr_accessible :distributor_ids, :description
  attr_accessible :require_ship_address, :tag_list

  validates_with DistributorsValidator

  scope :managed_by, lambda { |user|
    if user.has_spree_role?('admin')
      scoped
    else
      joins(:distributors).
        where('distributors_shipping_methods.distributor_id IN (?)', user.enterprises).
        select('DISTINCT spree_shipping_methods.*')
    end
  }

  scope :for_distributor, lambda { |distributor|
    joins(:distributors).
      where('enterprises.id = ?', distributor)
  }

  scope :by_name, order('spree_shipping_methods.name ASC')


  # Return the services (pickup, delivery) that different distributors provide, in the format:
  # {distributor_id => {pickup: true, delivery: false}, ...}
  def self.services
    Hash[
      Spree::ShippingMethod.
        joins(:distributor_shipping_methods).
        group('distributor_id').
        select("distributor_id").
        select("BOOL_OR(spree_shipping_methods.require_ship_address = 'f') AS pickup").
        select("BOOL_OR(spree_shipping_methods.require_ship_address = 't') AS delivery").
        map { |sm| [sm.distributor_id.to_i, {pickup: sm.pickup == 't', delivery: sm.delivery == 't'}] }
    ]
  end

  def within_zone?(order)
    if order.ship_address
      zone && zone.include?(order.ship_address)
    else
      true # Shipping methods are available before we've selected an address
    end
  end

  def has_distributor?(distributor)
    self.distributors.include?(distributor)
  end

  def adjustment_label
    I18n.t('shipping')
  end<commit_msg>Removed unused shipping_method.within_zone, customization not needed<commit_after>Spree::ShippingMethod.class_eval do
  acts_as_taggable

  has_many :distributor_shipping_methods
  has_many :distributors, through: :distributor_shipping_methods, class_name: 'Enterprise', foreign_key: 'distributor_id'

  after_save :touch_distributors
  attr_accessible :distributor_ids, :description
  attr_accessible :require_ship_address, :tag_list

  validates_with DistributorsValidator

  scope :managed_by, lambda { |user|
    if user.has_spree_role?('admin')
      scoped
    else
      joins(:distributors).
        where('distributors_shipping_methods.distributor_id IN (?)', user.enterprises).
        select('DISTINCT spree_shipping_methods.*')
    end
  }

  scope :for_distributor, lambda { |distributor|
    joins(:distributors).
      where('enterprises.id = ?', distributor)
  }

  scope :by_name, order('spree_shipping_methods.name ASC')


  # Return the services (pickup, delivery) that different distributors provide, in the format:
  # {distributor_id => {pickup: true, delivery: false}, ...}
  def self.services
    Hash[
      Spree::ShippingMethod.
        joins(:distributor_shipping_methods).
        group('distributor_id').
        select("distributor_id").
        select("BOOL_OR(spree_shipping_methods.require_ship_address = 'f') AS pickup").
        select("BOOL_OR(spree_shipping_methods.require_ship_address = 't') AS delivery").
        map { |sm| [sm.distributor_id.to_i, {pickup: sm.pickup == 't', delivery: sm.delivery == 't'}] }
    ]
  end

  def has_distributor?(distributor)
    self.distributors.include?(distributor)
  end

  def adjustment_label
    I18n.t('shipping')
  end
{'fraction_non_alphanumeric': 0.10732394366197183, 'fraction_numerical': 0.0011267605633802818, 'mean_word_length': 4.146376811594203, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3823773', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1114, 'n_words': 221}