<commit_before>module FriendlyId
  module ActiveRecord2

    module SimpleModel

      # Some basic methods common to {MultipleFinder} and {SingleFinder}.
      module SimpleFinder

        # The column used to store the friendly_id.
        def column
          "#{table_name}.#{friendly_id_config.column}"
        end

        # The model's fully-qualified and quoted primary key.
        def primary_key
          "#{quoted_table_name}.#{model_class.send :primary_key}"
        end

      end

      class MultipleFinder < Finders::MultipleFinder

        include SimpleFinder

        def find
          @results = with_scope(:find => options) { find_every :conditions => conditions }
          raise(::ActiveRecord::RecordNotFound, error_message) if @results.size != expected_size
          friendly_results.each { |result| result.friendly_id_status.name = result.friendly_id }
          @results
        end

        private

        def conditions
          ["#{primary_key} IN (?) OR #{column} IN (?)", unfriendly_ids, friendly_ids]
        end

        def friendly_results
          results.select { |result| friendly_ids.include? result.friendly_id.to_s }
        end

      end

      class SingleFinder < Finders::SingleFinder

        include SimpleFinder

        def find
          result = with_scope(:find => find_options) { find_initial options }
          raise ::ActiveRecord::RecordNotFound.new if !result
          result.friendly_id_status.name = id
          result
        end

        private

        def find_options
          {:conditions => {column => id}}
        end

      end
      
      # The methods in this module override ActiveRecord's +find_one+ and
      # +find_some+ to add FriendlyId's features.
      module FinderMethods
          protected

          def find_one(id, options)
            finder = SingleFinder.new(id, self, options)
            finder.unfriendly? ? super : finder.find
          end

          def find_some(ids_and_names, options)
            MultipleFinder.new(ids_and_names, self, options).find
          end
      end

      # These methods will be removed in FriendlyId 3.0.
      module DeprecatedMethods<commit_msg>Fixed finding simple friendly model by numeric id as string.<commit_after>module FriendlyId
  module ActiveRecord2

    module SimpleModel

      # Some basic methods common to {MultipleFinder} and {SingleFinder}.
      module SimpleFinder

        # The column used to store the friendly_id.
        def column
          "#{table_name}.#{friendly_id_config.column}"
        end

        # The model's fully-qualified and quoted primary key.
        def primary_key
          "#{quoted_table_name}.#{model_class.send :primary_key}"
        end

      end

      class MultipleFinder < Finders::MultipleFinder

        include SimpleFinder

        def find
          @results = with_scope(:find => options) { find_every :conditions => conditions }
          raise(::ActiveRecord::RecordNotFound, error_message) if @results.size != expected_size
          friendly_results.each { |result| result.friendly_id_status.name = result.friendly_id }
          @results
        end

        private

        def conditions
          ["#{primary_key} IN (?) OR #{column} IN (?)", unfriendly_ids, friendly_ids]
        end

        def friendly_results
          results.select { |result| friendly_ids.include? result.friendly_id.to_s }
        end

      end

      class SingleFinder < Finders::SingleFinder

        include SimpleFinder

        def find
          result = with_scope(:find => find_options) { find_initial options }
          raise ::ActiveRecord::RecordNotFound.new if !result
          result.friendly_id_status.name = id
          result
        end

        private

        def find_options
          {:conditions => {column => id}}
        end

      end
      
      # The methods in this module override ActiveRecord's +find_one+ and
      # +find_some+ to add FriendlyId's features.
      module FinderMethods
          protected

          def find_one(id, options)
            finder = SingleFinder.new(id, self, options)
            !finder.friendly? ? super : finder.find
          end

          def find_some(ids_and_names, options)
            MultipleFinder.new(ids_and_names, self, options).find
          end
      end

      # These methods will be removed in FriendlyId 3.0.
      module DeprecatedMethods
{'fraction_non_alphanumeric': 0.07414104882459313, 'fraction_numerical': 0.00135623869801085, 'mean_word_length': 2.1227946365561046, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '5387846', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1147, 'n_words': 322}