-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implement Coffee Chat Dao #598
base: main
Are you sure you want to change the base?
Conversation
[diff-counting] Significant lines: 115. |
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.
Good job! The design aligns with the other DAO classes. I left a comment on creating a new coffee chat instance, but otherwise this looks good.
|
||
if (prevChats.some((c) => c.members.includes(member1) && c.members.includes(member2))) { | ||
throw new Error( | ||
`Cannot create coffee chat with member. Previous coffee chats from previous semesters exist.` |
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.
There should probably also be a check to make sure a member cannot coffee chat themselves. There doesn't seem to be anything preventing this right now.
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.
Good catch, let's put this and the other validation logic in the API layer, not Dao.
…into set-up-coffee-chat-dao
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.
Generally, business logic such as rejecting duplicate chats should be done on the API layer, not Dao. Can you remove this here?
Feel free to read the git history/copy paste somewhere to use for the API implementation.
} | ||
|
||
/** | ||
* Deletes all coffee chat for all users |
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.
nit: *coffee chats
const [member1, member2] = coffeeChat.members; | ||
|
||
if (member1.netid === member2.netid) { | ||
throw new Error(`Cannot create coffee chat with yourself.`); |
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.
nit: no need for backticks if the string is not a template string
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.
interesting that eslint doesn't complain about this... 🤔
const prevChats2 = await this.getCoffeeChatsByUser(member2); | ||
const prevChats = [...prevChats1, ...prevChats2]; | ||
|
||
if (prevChats.some((c) => c.members.includes(member1) && c.members.includes(member2))) { |
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 would be very careful about this check. includes(...)
uses object equality and we've had a bug introduced in candidate decider in the past from this. Consider instead checking against netIDs or emails.
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.
Alternatively, we use lodash's isequal
which checks for deep equality for the profile update notification job. That can be used here.
Summary
This PR implements the creates the functions that are used to set up coffee chat DAO.
Some things to keep in mind:
Notion/Figma Link
https://www.notion.so/Dev-Roadmap-741d645c627a466da392fc8038ef0143?p=9719280ab9634834bba9d51a94ddeab8&pm=s