-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rating feature implementation #538
base: main
Are you sure you want to change the base?
Conversation
…ies and email input as first addition
…dropdown with all of the restaurants of CMUeats website
…restaurant to a friend
…dding a new Rating sysystem page
- Added backend functionality to calculate and fetch average ratings - Integrated frontend logic to display average ratings on eatery cards - Encountered some errors related to module imports and TypeScript definitions
… average rating functionalities
…, and average rating calculations
…e interactions in unit tests
…folder, in which I created feedbackController.js. Implemented core functions for managing feedback, including create, read, update, and delete operations. Structured the controller to integrate with the feedback model and routes.Added basic validation and error handling to ensure robust feedback processing.
…data using Mongoose. Included fields for user information, feedback content, timestamps, and associated references, ensuring appropriate data validation and default values. This model serves as the foundation for storing and managing feedback records in the database.
…ng middleware for JSON parsing, CORS handling, and logging. Integrated route handling for API endpoints and established a connection to the database using Mongoose. Configured the server to listen on a specified port, ensuring a functional entry point for the backend application.
…e and export a reusable email transporter using Nodemailer. Included setup for SMTP settings, authentication, and default sender information to streamline email-sending functionality across the application. Ensured flexibility for future enhancements, such as template integration or additional email providers.
…tainability and scalability
…mueats into rating-feature-backend
…d handling all ratings per restaurant.
…averaging ratings
This reverts commit 27ee003.
the commit. This ensures the comprehensivness of the rating feature, integrating the backend, frontend and testing.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@mthani2 is attempting to deploy a commit to the ScottyLabs Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for contributing! I'll review shortly |
*/ | ||
|
||
/** Simulated in-memory database */ | ||
const ratingsDb = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should set up an actual db before merging this (now that I'm thinking about it, maybe the backend should really belong with the dining-api
repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually on second thought, it might make more sense to keep the new rating api under cmueats
, since other services (like cmumaps) also use dining-api
.
}; | ||
|
||
try { | ||
const response = await fetch('/api/ratings', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we would preferably want users to be authenticated (either with cmu's IDP or whatever is currently being used for cmumaps/cmu courses) before letting them post a rating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't make sense here. Makes sense for CMU Courses as FCE data is restricted. Not for CMUEats ratings. Pitt students + visitors use. Should be more open here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe google SSO is fine then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it would be a rating system powered by CMU students for CMU students, but having it more open is also fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense for the most part if we don't consider visitors. The main issue, however, is that some Pitt students cross register/take classes at CMU. Thus, they may eat at CMU on a regular basis.
onChange={(e) => setSelectedRestaurant(e.target.value)} | ||
> | ||
<option value="">-- Select a Restaurant --</option> | ||
<option value="[email protected]">Stephanie's - Market c</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we generate these options based off of our api data instead?
Description
This pull request integrates the rating system feature, including backend endpoints, frontend functionality, and comprehensive testing. The feature enables users to submit ratings for restaurants in a newly added form page titled "Rate a Restaurant" and dynamically updates the displayed average ratings on restaurant cards (planned functionality). While the form is functional and most routes are written, the dynamic updates for the average rating on the eatery cards are not yet operational, as the cards still display "no rating" even after submission.
Motivation: The rating system enhances user interaction and feedback collection, allowing restaurants to monitor and improve their services based on real-time user reviews.
Review System feature: encompassing backend endpoints, frontend functionality, and the review submission flow. The feature allows users to leave detailed feedback for restaurants, including comments on food, service, and cleanliness, as well as an option to recommend the restaurant to others. The feedback is sent via email to the respective restaurant's email address, enabling restaurant managers to review and act on user feedback.
The Review System is accessible through a new "Leave a Review" button added to the navigation bar, which routes users to the ReviewFormPage. The form is fully functional, allowing for email submission, dropdown-based restaurant selection, and feedback input file. (#472)
Motivation: The review system enhances the CMUEats platform by offering a streamlined way for users to provide feedback to restaurants. This feature empowers restaurants to improve their services based on real user experiences and fosters better engagement between the dining establishments and their customers.
Dependencies:
Rating: No new external dependencies were introduced.
Review: This feature introduces Nodemailer as a new dependency to handle email delivery functionality.
Closes #360
and
Closes #472
Type of change
How Has This Been Tested?
Comprehensive testing was implemented to validate the feature:
Unit Tests for Rating: Tested the RatingModel methods to ensure data processing, such as creating, fetching, and calculating averages, functions correctly.
Integration Tests: Validated the backend endpoints (POST, GET, and average rating calculations) to ensure seamless communication between the frontend and backend.
Error Handling Tests: Verified server responses for invalid requests or edge cases.
Manual Testing: The feature was tested manually to verify user interactions, API calls, and dynamic updates on the frontend.
Unit Tests for Review:
Backend Testing:
Verified the feedbackController.js endpoints for CRUD operations, ensuring they process user-submitted feedback accurately.
Tested the emailTransporter.js utility to confirm successful email delivery with valid inputs.
Manual testing was performed using Mailtrap to simulate email delivery and debug authentication issues during development.
Frontend Testing:
Conducted manual testing of the review form on desktop browsers (Chrome, macOS Ventura) to verify input validation, submission flow, and error handling.
Checked dropdown functionality for restaurant selection and ensured email mapping correctness.
Integration Testing:
Validated the end-to-end flow from form submission on the frontend to email delivery via the backend.
Error Handling:
Tested various edge cases, such as invalid email formats and empty required fields, to ensure proper error messages are displayed.
Test Configuration:
Node.js version: 18.x
Desktop/Mobile: Desktop
OS: macOS Ventura
Browser: Chrome
Checklist:
Future Directions:
Resolve the issue with dynamically updating average ratings on eatery cards. While the backend is fully operational and returns accurate responses, the frontend is not yet reflecting the changes after a new rating is submitted.
--> Consider integrating a persistent database for ratings storage instead of the current in-memory database for scalability.