Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results obtained if interating a second time on the same cursor with a limit #42

Open
shnups opened this issue Oct 21, 2019 · 0 comments

Comments

@shnups
Copy link
Member

shnups commented Oct 21, 2019

This code snippet:

import logging

from appnexus import Campaign, connect

connect('XXXXXXXXXX', 'XXXXXXXXXX')

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

    results = [res for res in cursor]   

    print("Results ({}):\t{}".format(len(results), ','.join([str(r.id) for r in results])))
    print("Cursor.after:\tskip={}, limit={}, len={}, size={}" \
        .format(cursor._skip, cursor._limit, len(cursor), cursor.size()))

cursor = Campaign.find(advertiser_id=XXXXXXXXXX)
cursor.limit(50)
gather(cursor)
gather(cursor)

will output the following:

----------
Cursor.before:  skip=0, limit=50, len=228, size=50
Results (50):   XXXXXXXXXX, XXXXXXXXXX,...(redacted)...,XXXXXXXXXX,XXXXXXXXXX
Cursor.after:   skip=0, limit=50, len=228, size=50
----------
Cursor.before:  skip=0, limit=50, len=228, size=50
Results (0):
Cursor.after:   skip=0, limit=50, len=228, size=50

The cursor should be usable as many time as needed and should, if all things equal on AppNexus side (accessing objects that didn't changed in the meantime), retrieve the same output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant