Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Food Ratings (backend) #447

Open
bjsilva1 opened this issue May 24, 2024 · 0 comments · May be fixed by #453
Open

Food Ratings (backend) #447

bjsilva1 opened this issue May 24, 2024 · 0 comments · May be fixed by #453
Assignees

Comments

@bjsilva1
Copy link
Contributor

bjsilva1 commented May 24, 2024

Database

Under the dishes table, we should add a two new columns to allow us to calculate the average rating of the dish:

  • totalRating (an integer storing the sum of all ratings given)
  • numRatings (an integer storing the total number of ratings given)

Procedures

We will also need to add a few tRPC procedures to access this data on the frontend.

  • getRating - Given a dishID, returns the average rating of the dish. This is simply totalRating / numRatings
  • addRating - Given a dishID and rating, adds 1 to the dish's numRatings and rating to the totalRating
  • updateRating - Given a dishID, oldRating, and newRating, adds (newRating - oldRating) to the totalRating
@bjsilva1 bjsilva1 changed the title Food Reviews and Ratings Food Ratings (backend) May 24, 2024
@bjsilva1 bjsilva1 added the task label May 24, 2024
@dlustre dlustre self-assigned this Jun 3, 2024
@dlustre dlustre linked a pull request Jun 6, 2024 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants