I am working on an algorithm to deliver items to a user, where the user will then vote on each item presented to them. I am looking to provide the user with the items most recently posted to the database that this user has not voted on yet. The idea is to present the same post to as many different users as possible, but I want to make sure that one user never gets the same post twice (so they can't vote on the same post twice skewing the results). I will load the first 20 items my algorithm finds and refresh the list when the user gets down to 5 items.
The all items presented to the user will have a yes or no vote to them.
I know I could just store an array of post ID's the user votes on but to me this seems like it could space heavy and computation heavy after the user uses the app for a while. I am looking for suggestions on how to handle this problem. Any ideas would be great, might help spark an idea. If you would like more information just let me know, I'd be glad to provide it. Thanks!
Assuming that your post ID's have some kind of sequential order to them (and that the user votes on each post in order) you should only need to store the ID of the post that was most recently added. That way you can load the next 20 post ID's. If the user can vote on posts out of order you could store the sections of posts that they have voted on. (ex. user1 has voted on posts 3,4,5,6,9,10 so you store number pairs 3,6 and 9,10 indicating that all posts between thous ID's have been voted on thereby reducing the amount of space you use.)
Alternatively if you have the date and time stored for when the posts where made you can track the date and time of the last post the user voted on. From this you should be able to reduce the size needed for your array to the number of posts made at a given time stamp.