-
Notifications
You must be signed in to change notification settings - Fork 56
fix: QA feedbacks for assigning copilots #810
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
base: develop
Are you sure you want to change the base?
Conversation
@@ -74,14 +74,32 @@ module.exports = [ | |||
.update({ | |||
status: INVITE_STATUS.CANCELED, | |||
}) | |||
.then((updatedInvite) => { | |||
.then(async (updatedInvite) => { |
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.
The function passed to .then()
is now marked as async
, but there is no await
keyword used within it. If there is no asynchronous operation inside, consider removing async
to avoid unnecessary overhead.
// update the application if the invite | ||
// originated from copilot opportunity | ||
if (invite.applicationId) { | ||
const allPendingInvitesForApplication = await models.Sequelize.ProjectMemberInvite.getPendingInvitesForApplication(invite.applicationId); |
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.
Consider handling the case where getPendingInvitesForApplication
might return an error or unexpected result. Adding error handling can prevent potential issues if the database query fails.
// If only the current invite is the open one's | ||
// then the application status has to be moved to pending status | ||
if (allPendingInvitesForApplication.length === 1) { | ||
await models.Sequelize.CopilotApplication.update({ |
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.
Ensure that the update
operation on CopilotApplication
is correctly handling potential errors. Consider adding error handling to manage any exceptions that might occur during the update process.
// update the application if the invite | ||
// originated from copilot opportunity | ||
if (invite.applicationId) { | ||
req.log.info("Invite originated from the application id", invite.applicationId); |
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.
Consider using a more descriptive log message to provide context about the invite and its application ID. This can help in debugging and understanding the log output.
req.log.info("Invite originated from the application id", invite.applicationId); | ||
const allPendingInvitesForApplication = await models.Sequelize.ProjectMemberInvite.getPendingInvitesForApplication(invite.applicationId); | ||
|
||
req.log.info("All pending invites which are open", allPendingInvitesForApplication); |
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.
The log message could be more descriptive. Consider including additional context, such as the application ID or the number of pending invites, to make the logs more informative.
@@ -81,7 +81,7 @@ module.exports = [ | |||
.update({ | |||
status: newStatus, | |||
}) | |||
.then((updatedInvite) => { | |||
.then(async (updatedInvite) => { |
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.
The use of async
here suggests that there might be an await
call inside the function. Please ensure that any asynchronous operations inside this function are properly awaited to prevent potential issues with unhandled promises.
// originated from copilot opportunity | ||
if (updatedInvite.applicationId) { | ||
req.log.info("Invite originated from the application id", invite.applicationId); | ||
const allPendingInvitesForApplication = await models.Sequelize.ProjectMemberInvite.getPendingInvitesForApplication(invite.applicationId); |
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.
Consider handling the case where getPendingInvitesForApplication
might return an error or null. This could prevent potential runtime errors if the function does not behave as expected.
req.log.info("All pending invites which are open", allPendingInvitesForApplication); | ||
// If only the current invite is the open one's | ||
// then the application status has to be moved to pending status | ||
if (allPendingInvitesForApplication.length === 1) { |
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.
The comment 'If only the current invite is the open one's' seems unclear. Consider rephrasing for better clarity, such as 'If the current invite is the only open one'.
What's in this PR?