I am using Voting API with Fivestar. On my site users can comment on a node and leave a rating with the comment. These are aggregated and an average vote is displayed at the top of the node. The average rating for some of my nodes does not match what the average would be if you summed up the comment ratings and divided by the number of comments. Also the count is wrong.
I believe this happened because I manually converted an old Drupal 6 site to Drupal 7 so I manually entered some old reviews. Because I entered them from the same IP and within the threshold of time I believe the module does not count them.
I'm comfortable running SQL queries to fix this. I was able to enter the correct average and count records in the
votingapi_cache table. This temporarily fixed the problem, but later I deleted some spam comments, and then the rating was messed up again (I guess maybe deleting causes the
votingapi_cache table to be rebuilt?)
What is the correct way to fix this?
So there is more to the story. I just spent some time manually adding the records into the
votingapi_vote table. Then I added a new comment with a vote through my drupal site. This caused the
votingapi_cache to be rebuilt and I saw the the average vote and vote count were correct. I thought great problem solved.
Then I deleted my test comment and immediately the average and vote counts went to zero. Examining the
votingapi_vote table which I had just manually added records to, I saw that all records for that node id were gone. So deleting a comment deletes all records in
votingapi_vote table. Seemed fishy so I searched and found it's a bug in the fivestar module: Deletion of Anonymous Comments with Fivestar rating results in deletion of all votes for entity.
Pretty horrendous bug if you ask me. Don't think it's fixed in the module but that bug link has a patch for it which I will try out.