osome-iu/osometweet

Function that removes all filtered streaming rules

mr-devs opened this issue · 4 comments

Since it seems like filtered streaming rules persist unless the user removes them (see #85 for an issue seeking to confirm this is true), a simple function that removes all existing filter rules seems like it would be useful.

Something like the below

def remove_all_filter_rules(ot)
    current_rules = ot.get_filtered_stream_rule()
    print(f'The current filtered stream rules are:\n{current_rules}\n')
    
    # Get all streaming rule ids and then remove them
    all_rules = [rule["id"] for rule in current_rules["data"]]
    delete_rule = {'delete': {'ids': all_rules}}
    response = ot.set_filtered_stream_rule(rules=delete_rule)
    print(f"API response from deleting rules:\n{response}\n")

I'm ok with this.

However, I think that we might want to discuss how many convenience functions are too little/many? That is going to depend on who we want our target user base to be. IIRC, Twitter has said that they expect this version of the API to evolve faster than the prior version. Depending on how often they implement breaking changes, maintaining a large number of convenience functions for users that might not be our target user base could become onerous really fast.

That's a good point. Probably it's best to keep things a bit more bare-bones.

I think this issue is super low-priority, it was just something that popped into my head and I wanted to jot it down.

I don't really have a sense of a hard number that would be too little/many. Any thoughts are welcome.

This is a really good point!

Maybe we can divide things into two categories: the core lib (functions that are imported in __init__.py) and the other convenience functions (such as utils.py and wrangle.py).

For the core lib, let's keep the functions simple, straightforward, and up to date. Hopefully, this will make it easier for us to keep up with Twitter's pace.

For the convenience functions, we can be more flexible. If we think a function is useful for ourselves, let's add it. And if it breaks in the future, so be it. We should be good as long as the core lib is stable.

So it seems like a good general rule would be: non-essential/extra features should be kept out of the core library.

This sounds like the best of both worlds to me. After all, convenience functions are nice to have (if they don't break), so I think we'd like the freedom to develop these.

That said, I'll leave this issue open because I think it will be useful, it seems simple enough to develop, and we can just make sure to keep it out of the core lib. Probably utils.py is the best place for this function.