Skip to content

feat: Add endpoint and controller to check for events on a travel date.#250

Open
vendz wants to merge 3 commits into
mainfrom
chore/seperate-travel-event
Open

feat: Add endpoint and controller to check for events on a travel date.#250
vendz wants to merge 3 commits into
mainfrom
chore/seperate-travel-event

Conversation

@vendz
Copy link
Copy Markdown
Member

@vendz vendz commented Dec 29, 2025

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 a new feature designed to enhance the travel booking system by providing visibility into upcoming events. It adds a dedicated API endpoint and controller logic that queries the event database for any 'Utsavs' scheduled at the 'Research Centre' from the current day, returning a simple indication of their presence. This allows for better planning or awareness regarding events coinciding with travel dates.

Highlights

  • New API Endpoint: A new GET API endpoint /events has been introduced under the client travel booking routes.
  • Event Checking Functionality: This new endpoint allows checking for upcoming events ('Utsavs') at the 'Research Centre' location from the current date onwards.
  • Database Integration: The UtsavDb model has been integrated into the travel booking controller to facilitate querying event data.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new endpoint /events to check for Utsav events. The implementation in the controller has a critical bug that will cause a runtime error due to an undefined variable. Additionally, it uses a hardcoded string instead of a constant. There's also a potential logic issue where the function's behavior (checking for any future events) doesn't seem to match its name and the PR's intent (checking for events on a specific travel date). I've provided comments with suggestions to fix these issues.

Comment on lines +146 to +151
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There are a couple of issues in this query:

  1. The Op object from Sequelize is not defined, which will cause a ReferenceError. You should use Sequelize.Op instead, as Sequelize is already imported.
  2. The string 'Research Centre' is hardcoded. It's better to use the RESEARCH_CENTRE constant from ../../config/constants.js for consistency and maintainability. Please remember to import it.
Suggested change
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
end_date: {
[Sequelize.Op.gte]: today
},
location: {
[Sequelize.Op.eq]: RESEARCH_CENTRE
}

Comment on lines +141 to +161
export const checkEventsOnTravelDate = async (req, res) => {
const today = moment().format('YYYY-MM-DD');

const utsavs = await UtsavDb.findAll({
where: {
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
}
});

return res.status(200).send({
message: 'fetched results',
data: {
utsav: utsavs.length > 0
}
});
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function name checkEventsOnTravelDate and the PR title suggest it checks for events on a specific date, but the implementation checks for any events from today onwards and does not accept a date parameter. This might be misleading or not what the user of the API expects.

If the goal is to check for a specific date, you should get the date from the request query and adjust the database query. For example:

// Get date from query, default to today
const travelDate = req.query.date ? moment(req.query.date).format('YYYY-MM-DD') : moment().format('YYYY-MM-DD');

// ... later in the query
const utsavs = await UtsavDb.findAll({
  where: {
    start_date: { [Sequelize.Op.lte]: travelDate },
    end_date: { [Sequelize.Op.gte]: travelDate },
    location: { [Sequelize.Op.eq]: RESEARCH_CENTRE }
  }
});

If checking from today onwards is the intended behavior, consider renaming the function to something like checkUpcomingEvents to better reflect its purpose.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new endpoint to check for upcoming events (utsavs) at the Research Centre. The endpoint returns whether there are any active events, which can be useful for travel booking considerations.

Key changes:

  • New GET /events endpoint in the travel booking routes
  • Controller function checkEventsOnTravelDate that queries the UtsavDb for active events
  • Minor formatting improvement (spacing fix) in the existing CancelTravel function

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
routes/client/travelBooking.routes.js Adds new /events route and imports the checkEventsOnTravelDate controller function
controllers/client/travelBooking.controller.js Implements checkEventsOnTravelDate function to query events, adds UtsavDb import, and fixes spacing in existing code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +141 to +161
export const checkEventsOnTravelDate = async (req, res) => {
const today = moment().format('YYYY-MM-DD');

const utsavs = await UtsavDb.findAll({
where: {
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
}
});

return res.status(200).send({
message: 'fetched results',
data: {
utsav: utsavs.length > 0
}
});
};
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function uses the Op operator from Sequelize but it's not imported. You need to add the import statement at the top of the file.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +161
export const checkEventsOnTravelDate = async (req, res) => {
const today = moment().format('YYYY-MM-DD');

const utsavs = await UtsavDb.findAll({
where: {
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
}
});

return res.status(200).send({
message: 'fetched results',
data: {
utsav: utsavs.length > 0
}
});
};
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title indicates this endpoint should check for events on a travel date, but the function doesn't accept any date parameter from the request. It only checks against today's date. Consider accepting a date parameter from req.query to allow checking events for a specific travel date, which would align with the PR's stated purpose.

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +151
location: {
[Op.eq]: 'Research Centre'
}
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Op.eq for simple equality checks is unnecessary. You can directly assign the value in the where clause instead of using the operator. This would simplify the code.

Suggested change
location: {
[Op.eq]: 'Research Centre'
}
location: 'Research Centre'

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +161
export const checkEventsOnTravelDate = async (req, res) => {
const today = moment().format('YYYY-MM-DD');

const utsavs = await UtsavDb.findAll({
where: {
end_date: {
[Op.gte]: today
},
location: {
[Op.eq]: 'Research Centre'
}
}
});

return res.status(200).send({
message: 'fetched results',
data: {
utsav: utsavs.length > 0
}
});
};
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new controller function lacks test coverage. Other client controller tests exist in the tests/controllers/client directory, such as adhyayanBooking, flatBooking, and mumukshuBooking. Consider adding tests for this new endpoint to maintain consistency with the existing test coverage in the codebase.

Copilot uses AI. Check for mistakes.
});

return res.status(200).send({
message: 'fetched results',
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response message 'fetched results' uses lowercase, which is inconsistent with other success messages in the codebase that typically use title case or uppercase for the first letter, such as 'Fetched data' (line 64) in the same file.

Suggested change
message: 'fetched results',
message: 'Fetched results',

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants