Saving state in time - "snapshot"
Hello everyone. I'm adding some gameification to a project that I'm currently working on really sporadically. Let's say we have Users and Posts. A User can have multiple Posts and one post belongs to only one user.
I want to create a Leaderboard for this. Every day at 19.00 I'd like to create a Leaderboard with the User and their number of posts. Not all the users are part of a leaderboard, they need to be added to one to be calculated.
How would you guys implement this? My idea was to have a Leaderboard entity class basically like this
This way when I retrieve a specific Leaderboard, I can see directly the amount of posts that the user has created.
Another way would be to create the leaderboard and through SQL get the posts that were created <= LeaderBoardEntity.CreatedAt.
Anyone thinks of anything else?
1 Reply
Any suggestion on this one?