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

780 refactor shift the logic for checking win condition #876

Merged

Conversation

pmarsh-scottlogic
Copy link
Contributor

@pmarsh-scottlogic pmarsh-scottlogic commented Mar 25, 2024

Description

Moves the code that checks whether the user has won. It used to live within the sendEmail, deep within the call stack for sending a chat message. I've brought it right out to the top level.

Notes

  • moves checkLevelWinCondition and checkSubjectAndBodyContains from email.ts to a new file winCondition.ts.
  • calls checkLevelWinCondition from handleChatToGPT.
  • wonLevel no longer being passed all the way back up through the call stack.
  • converts a few interface definitions to type definitions.
  • testing for winning a level is now handled in the unit tests for winCondition.ts and chatController.ts.

Checklist

Have you done the following?

  • Linked the relevant Issue
  • Added tests
  • Ensured the workflow steps are passing

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

Lovely work, so much cleaner 💎

As I seem unable to let a PR through without a single comment 😅 I've made one small suggestion, but feel free to ignore it!

@@ -423,7 +409,6 @@ async function chatGptSendMessage(

const chatResponse: ChatResponse = {
completion: finalToolCallResponse.gptReply.completion,
wonLevel: finalToolCallResponse.wonLevel,
Copy link
Member

Choose a reason for hiding this comment

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

I love how many places this has been removed from 🥳

backend/src/winCondition.ts Outdated Show resolved Hide resolved
expect.objectContaining({ wonLevel: true })
);
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Nice tests, really clear 👍

@pmarsh-scottlogic pmarsh-scottlogic merged commit cd4bef7 into dev Mar 25, 2024
2 checks passed
@pmarsh-scottlogic pmarsh-scottlogic deleted the 780-refactor-shift-the-logic-for-checking-win-condition branch March 25, 2024 16:54
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.

Refactor: Shift the logic for checking win condition
2 participants