updating guest creation and check endpoint for adding dob#222
Conversation
Summary of ChangesHello @vendz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces significant improvements to the guest booking and management system. It ensures data completeness by making the date of birth a mandatory field during guest creation and enhances the guest lookup functionality to provide more detailed information, including the guest's type and date of birth. The underlying guest creation logic has been refactored to support seamless updates for existing guests, alongside minor code formatting and dependency metadata adjustments. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the guest creation and checking endpoints to include the date of birth (dob). The changes look good overall. I've identified a performance issue in checkGuests where an extra database query is made, and I've suggested a refactor to use a single query with an include. I also found a minor issue in createGuestsHelper where the returned array contains mixed data types, and I've provided a suggestion to make it consistent.
| const allGuests = [ | ||
| ...guestsToUpdate.map((g) => ({ ...g })), | ||
| ...createdGuests | ||
| ]; |
There was a problem hiding this comment.
The allGuests array is constructed with a mix of plain JavaScript objects from guestsToUpdate and Sequelize model instances from createdGuests. This can lead to inconsistent data structures in the API response. It's better to convert Sequelize instances to plain objects before returning them. Also, the expression ...guestsToUpdate.map((g) => ({ ...g })) is unnecessarily complex and can be simplified.
| const allGuests = [ | |
| ...guestsToUpdate.map((g) => ({ ...g })), | |
| ...createdGuests | |
| ]; | |
| const allGuests = [ | |
| ...guestsToUpdate, | |
| ...createdGuests.map((g) => g.toJSON()) | |
| ]; |
| const msg = missing | ||
| .map((m) => `Guest ${m.index + 1} has missing [${m.fields.join(', ')}]`) | ||
| .join('; '); | ||
| throw new ApiError(400, msg); |
There was a problem hiding this comment.
so in frontend we are making dob as required field right? This is thrown only when they don't enter dob
There was a problem hiding this comment.
diid you wnated to checkin this?
No description provided.