I have a Rails application that uses GetStream to implement a newsfeed functionality. Everytime a user logs in, the user follows every single location they have access to. The only issue is that a user could possibly belong to 1000+ stores making performance a huge issue.
After setting up the user the first time (the longest time because all follows need to be created), what would be the correct way to prevent duplicate follows? Would it be to set a boolean flag on the user to not follow everytime they log in and only create a new follow each time the user is given access to a new location?
Or maybe GetStream is already smart enough to notice duplicates so it doesn't write each time it receives the same information?
Stream will ignore requests that try to create existing follow relationships. You should consider using the follow many batch API if you need to create this many follow relationships at once. You can find more about it on the documentation: https://getstream.io/docs/#batch-follow