<commit_before>module Spree
  class Taxon < ActiveRecord::Base
    acts_as_nested_set dependent: :destroy

    belongs_to :taxonomy, class_name: 'Spree::Taxonomy'
    has_many :classifications, dependent: :delete_all
    has_many :products, through: :classifications

    before_create :set_permalink

    attr_accessible :name, :parent_id, :position, :icon, :description, :permalink, :taxonomy_id,
                    :meta_description, :meta_keywords, :meta_title

    validates :name, presence: true

    has_attached_file :icon,
      styles: { mini: '32x32>', normal: '128x128>' },
      default_style: :mini,
      url: '/spree/taxons/:id/:style/:basename.:extension',
      path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
      default_url: '/assets/default_taxon.png'

    include Spree::Core::S3Support
    supports_s3 :icon

    include Spree::Core::ProductFilters  # for detailed defs of filters

    # indicate which filters should be used for a taxon
    # this method should be customized to your own site
    def applicable_filters
      fs = []
      # fs << ProductFilters.taxons_below(self)
      ## unless it's a root taxon? left open for demo purposes

      fs << Spree::Core::ProductFilters.price_filter if Spree::Core::ProductFilters.respond_to?(:price_filter)<commit_msg>Bugfix: Taxons could not be ordered<commit_after>module Spree
  class Taxon < ActiveRecord::Base
    acts_as_nested_set dependent: :destroy

    belongs_to :taxonomy, class_name: 'Spree::Taxonomy'
    has_many :classifications, dependent: :delete_all
    has_many :products, through: :classifications

    before_create :set_permalink

    attr_accessible :name, :parent_id, :position, :icon, :description, :permalink, :taxonomy_id,
                    :meta_description, :meta_keywords, :meta_title

    validates :name, presence: true

    has_attached_file :icon,
      styles: { mini: '32x32>', normal: '128x128>' },
      default_style: :mini,
      url: '/spree/taxons/:id/:style/:basename.:extension',
      path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
      default_url: '/assets/default_taxon.png'

    default_scope order: "#{self.table_name}.position"

    include Spree::Core::S3Support
    supports_s3 :icon

    include Spree::Core::ProductFilters  # for detailed defs of filters

    # indicate which filters should be used for a taxon
    # this method should be customized to your own site
    def applicable_filters
      fs = []
      # fs << ProductFilters.taxons_below(self)
      ## unless it's a root taxon? left open for demo purposes

      fs << Spree::Core::ProductFilters.price_filter if Spree::Core::ProductFilters.respond_to?(:price_filter)
{'fraction_non_alphanumeric': 0.10706401766004416, 'fraction_numerical': 0.008830022075055188, 'mean_word_length': 3.8553571428571427, 'pattern_counts': {'":': 0, '<': 13, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5261440', 'n_tokens_mistral': 858, 'n_tokens_neox': 832, 'n_words': 207}