-
-
Notifications
You must be signed in to change notification settings - Fork 456
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
SubredditFlairTemplates.update nullifies/overwrites existing values if not given #1139
Comments
I should be able to get to this sometime next week, but if anyone else wants to pick it up then feel free. |
After investigating this, it seems that this is default behaviour of the API endpoint, so to improve this we would first need to fetch/recieve the existing data and then apply the changes given. There are a few ways this could be done. I'd like to get discussion or a decision on what to go with before I implement it fully, as they have different pros and cons. In each case, once we had the existing data we would just apply the non None changes given as input params to the existing dict and then post that. 1). Simply fetch the existing data in the 2). Cache the existing data when the class is initialized or when it's iterated on so we don't have to round trip all the time. Downside is potential outdated data. 3). Allow for an I'm not exactly sure how caching works overall in PRAW and how big an issue the possibility of outdated data would be. If that can be minimized then option 2 is probably ideal, otherwise option 1 is still a good option even with the extra round trip as it will lead to best user experience except for that extra delay. |
My proposed flair class in #1231 should solve this problem because it has it's own built-in update function and therefore it will use previously existing models. However, it is optional, so I think the best idea is to fetch the data matching the template id, as unless one subreddit has an insane amount of templates, there should not be a noticeable problem. I think caching results for an hour would be acceptable, and maybe we could do that by having a dict in the reddit instance, like cached_data = {"subreddits":
[{"name": <subredditname>, "link_flair_data":
{"timestamp": <UNIX timestamp>, "data": [<Data retrieved through iter(FlairTemplates)>]
}
}]
} However, this seems very convoluted and annoying to integrate into existing functions. Thoughts? |
@PythonCoderAS I think introducing a cache system would have unintended negative side effects. For example, when flairs are updated outside of a certain program, that program would be unable to get the new flairs until the hour is up. |
In addition, the data associated with flairs is not very large, so a cache really wouldn't speed anything up. |
So should we just pull data from reddit? |
I think the proposed option #1 seems to make sense. I would like to avoid any sort of caching layer. |
Issue Description
The current SubredditFlairTemplates.update method nullifies/overwrites existing values if not given as inputs to the method, instead of retaining them and only modifying the inputs given.
Although this is documented, it would be preferable to only update the values given as inputs to the call.
The text was updated successfully, but these errors were encountered: