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

feat: develop complete retro #33

Merged
merged 2 commits into from
Apr 28, 2024
Merged

Conversation

nishadipri
Copy link
Collaborator

@nishadipri nishadipri commented Apr 24, 2024

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

  • I have performed a self-review of my own code
  • I have followed the name conventions for CSS Classnames and filenames, Components names and filenames, Style filenames, if you are in doubt check the the project README.MD and here https://github.com/HackYourFuture-CPH/curriculum/blob/master/review/review-checklist.md
  • I have commented my code, particularly in hard-to-understand areas, if you code was simple enough mark the box anyway
  • I have made corresponding changes to the documentation, if you code was simple enough mark the box anyway
  • This PR is ready to be merged and not breaking any other functionality

@nishadipri nishadipri requested a review from a team as a code owner April 24, 2024 07:41
Comment on lines +67 to +71
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)}
`);
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Comment on lines +141 to +146
const renderTeamMembers = (members) =>
members.map((member) => (
<option key={member.id} value={member.id}>
{member.first_name} {member.last_name}
</option>
));
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@komalranjan9
Copy link
Collaborator

@nishadipri I am going to merge to main, as you asked.

@komalranjan9 komalranjan9 merged commit 0f33da9 into main Apr 28, 2024
4 checks passed
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