Skip to content

Cursor's skip setting is lost after an iteration on the cursor #41

Description

@shnups

Using the following code snippet:

import logging

from appnexus import Campaign, connect

logging.basicConfig()
logging.getLogger("appnexus-client").setLevel(logging.DEBUG)

connect('XXXXXXXXXX', 'XXXXXXXXXX')

def gather(cursor):
    print("----------")
    print("Cursor.before:\tskip={}, limit={}".format(cursor._skip, cursor._limit))

    results = [res for res in cursor]   

    print("Results:\t{}".format(len(results)))
    print("Cursor.after:\tskip={}, limit={}".format(cursor._skip, cursor._limit))

cursor = Campaign.find(advertiser_id=XXXXXXXXXX)
cursor.skip(10)
gather(cursor)

The following will be outputted (authentication-related logs redacted):

----------
Cursor.before:  skip=100, limit=inf
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=0&num_elements=1 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=0&num_elements=100 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=100&num_elements=100 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=200&num_elements=100 None
Results:        128
Cursor.after:   skip=0, limit=inf
----------
Cursor.before:  skip=0, limit=inf
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=0&num_elements=1 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=0&num_elements=100 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=100&num_elements=100 None
DEBUG:appnexus-client:{'Authorization': 'XXXXXXXXXX'} https://api.appnexus.com/campaign?advertiser_id=XXXXXXXXXX&start_element=200&num_elements=100 None
Results:        228
Cursor.after:   skip=0, limit=inf

I believe that a value to skip should be set once and maintain during the lifetime of the cursor instance, or at least until it is set again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions