<commit_before>module PaginateAlphabetically
  module ActiveRecord
    def paginate_alphabetically(params)
      @attribute = params[:by]
      self.extend ClassMethods
    end

    module ClassMethods
      def pagination_letters
        all.sort_by{|obj| obj.send(@attribute).upcase}.group_by {|group| group.send(@attribute)[0].chr.upcase}.keys
      end

      def first_letter
        first_instance = find(:first, :order => @attribute, :conditions => ["#{@attribute.to_s} >= ?", 'a'])
        return 'A' if first_instance.nil?
        first_instance.send(@attribute)[0].chr.upcase
      end

      def alphabetical_group(letter = nil)
        find(:all, :conditions => ["#{@attribute.to_s} LIKE ?", "#{letter || first_letter}%"], :order => @attribute)
      end
    end
  end
end<commit_msg>Fixed case-insensitivity on Postgres<commit_after>module PaginateAlphabetically
  module ActiveRecord
    def paginate_alphabetically(params)
      @attribute = params[:by]
      self.extend ClassMethods
    end

    module ClassMethods
      def pagination_letters
        all.sort_by{|obj| obj.send(@attribute).upcase}.group_by {|group| group.send(@attribute)[0].chr.upcase}.keys
      end

      def first_letter
        first_instance = find(:first, :order => @attribute, :conditions => ["#{@attribute.to_s} >= ?", 'a'])
        return 'A' if first_instance.nil?
        first_instance.send(@attribute)[0].chr.upcase
      end

      def alphabetical_group(letter = nil)
        letter ||= first_letter
        find(:all, :conditions => ["LOWER(#{@attribute.to_s}) LIKE ?", "#{letter.downcase}%"], :order => @attribute)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13539769277474195, 'fraction_numerical': 0.0024286581663630845, 'mean_word_length': 3.2583979328165373, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2548706', 'n_tokens_mistral': 509, 'n_tokens_neox': 492, 'n_words': 103}