Imagine a simple PHP application where an user can post notes and the other users can upvote or downvote them.
We want to implement a system where each note has a different rating (normal, good, great ...) based on the number of upvotes and downvotes it has.
My question is: When should I handle these rating changes?
My first idea was to check every time an user votes on a note if the vote doesn't change it's rating (e.g. from normal to good) but considering that voting on notes will be one of the most frequently used features on our site, it might slow down the site a lot.
We could also implement a cron job which fires every, let's say, half an hour and checks if the number of votes on every note corresponds to its rating but I suppose that would be a waste of our resources since most of the notes might not have been voted on during that time interval.