-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: develop complete retro #33
Conversation
const results = await knex.raw(` | ||
select \`Employees\`.first_name, \`Employees\`.last_name, \`TeamMembers\`.id from \`Employees\` | ||
inner join \`TeamMembers\` on \`TeamMembers\`.employee_id = \`Employees\`.id | ||
where \`TeamMembers\`.team_id = ${Number(teamId)} | ||
`); |
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 used ChatGPT to propose a better way of doing this query:
const getTeamMembers = async (params) => {
const { teamId } = params;
// Using Knex's query builder to construct the SQL query
const results = await knex('Employees')
.select('Employees.first_name', 'Employees.last_name', 'TeamMembers.id')
.join('TeamMembers', 'TeamMembers.employee_id', '=', 'Employees.id')
.where('TeamMembers.team_id', Number(teamId)); // Safely parameterized
return {
teamMembers: results[0],
};
};
Try it out and see if it works.
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 have tried this. But it's given me some errors.
const renderTeamMembers = (members) => | ||
members.map((member) => ( | ||
<option key={member.id} value={member.id}> | ||
{member.first_name} {member.last_name} | ||
</option> | ||
)); |
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.
Any special reason for having this as a function instead of doing a map
inside the <select>
further down?
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.
Separated the mapping logic as its own function because it's easy to read and clear.
@nishadipri I am going to merge to main, as you asked. |
Description
Uploading Screen Recording 2024-04-28 at 07.18.18.mov…
Fixes # (issue)
How to test?
Please provide a short summary how your changes can be tested?
Checklist