<commit_before>module Zendesk2::Searchable
  def self.included(klass)
    klass.send(:extend, Zendesk2::Searchable::Attributes)
  end

  def search(parameters)
    body = connection.send(self.class.search_request, parameters.merge("type" => self.class.search_type)).body
    if data = body.delete("results")
      load(data)
    end
    merge_attributes(body)
  end

  module Attributes
    attr_accessor :search_type
    attr_writer :search_request

    def search_request
      @search_request ||= :search
    end
  end<commit_msg>correctly handle paging during searches<commit_after>module Zendesk2::Searchable
  def self.included(klass)
    klass.send(:extend, Zendesk2::Searchable::Attributes)
  end

  def search(parameters)
    body = connection.send(self.class.search_request, parameters.merge("type" => self.class.search_type)).body
    if data = body.delete("results")
      collection = self.clone.load(data)
      collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
      collection
    end
  end

  module Attributes
    attr_accessor :search_type
    attr_writer :search_request

    def search_request
      @search_request ||= :search
    end
  end
{'fraction_non_alphanumeric': 0.10281923714759536, 'fraction_numerical': 0.003316749585406302, 'mean_word_length': 4.050209205020921, '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': '6582035', 'n_tokens_mistral': 372, 'n_tokens_neox': 362, 'n_words': 72}