quiltingcode / happening-react-frontend

A react-based social media platform for sharing events in a small town
https://happening-react.herokuapp.com/
2 stars 1 forks source link

BUG: Average rating not recalculating on submit new review #58

Open quiltingcode opened 1 year ago

quiltingcode commented 1 year ago

Describe the bug When a new review is posted , the review count goes up, but the average rating does not change until the page is refreshed.

I can't figure out what is the calculation to use for the average rating field.

At the moment I have (Average Rating + new Rating) / Review count - but this is technically not correct. It shouldn't be average rating, it should look at all existing reviews and add the individual ratings together from scratch and then re-average them all at the same time. Otherwise, a different result is produced. Right now , it's not doing anything

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Reviews'
  2. Click on '.Post a review'
  3. Add a rating and a review comment
  4. Click Post
  5. See error - review count up by 1 but the average rating has not changed.

Expected behavior Average rating should change

Screenshots image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

quiltingcode commented 1 year ago

Tutor has tested this this morning, and the average rating seems to be updating now.

quiltingcode commented 1 year ago

I've just tested this during the responsive testing on https://www.responsivedesignchecker.com/ and the rating is recalculating correctly as well. Need to keep an eye on this.

quiltingcode commented 1 year ago

Image

worked