mercredi 9 septembre 2020

5 Star-Rating in Rails API

I'm learning rails and my work is from the backend side and I'm going to make a restaurant rating system in which a user can rate a restaurant he checkin before. I'm getting user_id & rating e.g (4,5,3) from front-end now I don't know how to get the overall restaurant rating. I have an idea below

s = sum of rating on a particular restaurant 
t = total no of rating on that reataurant 

Restaurant overall rating = s/t 

Here im getting these values from my Rating model where I store resturant_ID , User_id , user_rating, Overall_rating .

i don't know here im going on the right path or not but I need guidness from seniors.

Aucun commentaire:

Enregistrer un commentaire