<commit_before>module Octobat
  class ListObject < OctobatObject
    include Enumerable
    include Octobat::APIOperations::List
    
    attr_accessor :filters, :cursors
    
    def initialize(*args)
      super
      self.filters = {}
      self.cursors = {}
    end

    def [](k)
      case k
      when String, Symbol
        super
      else
        raise ArgumentError.new("You tried to access the #{k.inspect} index, but ListObject types only support Octobat keys. (HINT: List calls return an object with a 'data' (which is the data array). You likely want to call #data[#{k.inspect}])")
      end
    end

    def each(&blk)
      self.data.each(&blk)
    end
    
    def empty?
      self.data.empty?
    end

    def retrieve(id, api_key=nil)
      api_key ||= @api_key
      response, api_key = Octobat.request(:get, "#{url}/#{CGI.escape(id)}", api_key)
      Util.convert_to_octobat_object(response, api_key)
    end

    def create(params={}, opts={})
      api_key, headers = Util.parse_opts(opts)
      api_key ||= @api_key
      response, api_key = Octobat.request(:post, url, api_key, params, headers)
      Util.convert_to_octobat_object(response, api_key)
    end

    
    def next_page_params(params={}, opts={})
      return nil if !has_more
      last_id = data.last.id

      params = filters.merge({
        starting_after: last_id
      }).merge(params)
    end


    def previous_page_params(params={}, opts={})
      return nil if cursors[:starting_after].nil? || cursors[:starting_after].empty?
      first_id = data.first.id
<commit_msg>:package: => bu> issue on previous page params<commit_after>module Octobat
  class ListObject < OctobatObject
    include Enumerable
    include Octobat::APIOperations::List
    
    attr_accessor :filters, :cursors
    
    def initialize(*args)
      super
      self.filters = {}
      self.cursors = {}
    end

    def [](k)
      case k
      when String, Symbol
        super
      else
        raise ArgumentError.new("You tried to access the #{k.inspect} index, but ListObject types only support Octobat keys. (HINT: List calls return an object with a 'data' (which is the data array). You likely want to call #data[#{k.inspect}])")
      end
    end

    def each(&blk)
      self.data.each(&blk)
    end
    
    def empty?
      self.data.empty?
    end

    def retrieve(id, api_key=nil)
      api_key ||= @api_key
      response, api_key = Octobat.request(:get, "#{url}/#{CGI.escape(id)}", api_key)
      Util.convert_to_octobat_object(response, api_key)
    end

    def create(params={}, opts={})
      api_key, headers = Util.parse_opts(opts)
      api_key ||= @api_key
      response, api_key = Octobat.request(:post, url, api_key, params, headers)
      Util.convert_to_octobat_object(response, api_key)
    end

    
    def next_page_params(params={}, opts={})
      return nil if !has_more
      last_id = data.last.id

      params = filters.merge({
        starting_after: last_id
      }).merge(params)
    end


    def previous_page_params(params={}, opts={})
      return nil if !has_before
      first_id = data.first.id

{'fraction_non_alphanumeric': 0.11089743589743589, 'fraction_numerical': 0.0, 'mean_word_length': 2.6460280373831777, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5869884', 'n_tokens_mistral': 1017, 'n_tokens_neox': 998, 'n_words': 261}