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

Support for an initial before_attribute in stream_generator #1983

Merged
merged 9 commits into from Oct 8, 2023

Conversation

c0d3rman
Copy link
Contributor

@c0d3rman c0d3rman commented Oct 6, 2023

Adds a continue_after_id parameter to the stream_generator function so that an initial value for before_attribute can be set.

Example use case: a script wants to process all new comments from a sub since the last time it's been run. It keeps the fullname of the last comment it saw on its previous run and wants to stream all comments starting from the one after that. It can do:

for comment in reddit.sub.stream.comments(continue_after_id=last_seen_fullname):
    # Do things...

praw/models/util.py Outdated Show resolved Hide resolved
Copy link
Member

@LilSpazJoekp LilSpazJoekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for a few concerns.

Could you also add an entry in CHANGES.rst?

tests/integration/models/reddit/test_subreddit.py Outdated Show resolved Hide resolved
praw/models/util.py Outdated Show resolved Hide resolved
praw/models/util.py Outdated Show resolved Hide resolved
@c0d3rman
Copy link
Contributor Author

c0d3rman commented Oct 8, 2023

For CHANGES.rst, should I increment the version number? (And if so do I need to do that elsewhere as well?) Or should I put it in Unreleased?

@LilSpazJoekp
Copy link
Member

Put it in unreleased under the **Added** header.

@c0d3rman
Copy link
Contributor Author

c0d3rman commented Oct 8, 2023

Requested changes have been made.

Copy link
Member

@LilSpazJoekp LilSpazJoekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I just have a final couple of comments.

CHANGES.rst Outdated Show resolved Hide resolved
tests/integration/models/reddit/test_subreddit.py Outdated Show resolved Hide resolved
@LilSpazJoekp LilSpazJoekp enabled auto-merge (squash) October 8, 2023 21:32
@LilSpazJoekp LilSpazJoekp merged commit 7dde814 into praw-dev:master Oct 8, 2023
15 checks passed
@c0d3rman c0d3rman deleted the before_attribute branch October 8, 2023 21:34
@LilSpazJoekp
Copy link
Member

Merged in! 🎉Thank you!

@c0d3rman
Copy link
Contributor Author

c0d3rman commented Oct 8, 2023

Thanks for all your help!

@c0d3rman
Copy link
Contributor Author

c0d3rman commented Oct 8, 2023

By the way, question: what's the release schedule of PRAW like? I want to use this in a project of mine but not sure if to just wait or to hack around it in the meantime

@LilSpazJoekp
Copy link
Member

There isn't really a release schedule. However, you can do pip install --upgrade https://github.com/praw-dev/praw/archive/master.zip to install the dev version.

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

Successfully merging this pull request may close these issues.

None yet

3 participants