Skip to content

solution#939

Open
dmdamyan wants to merge 2 commits into
mate-academy:masterfrom
dmdamyan:develop
Open

solution#939
dmdamyan wants to merge 2 commits into
mate-academy:masterfrom
dmdamyan:develop

Conversation

@dmdamyan
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Your implementation is well-structured with proper separation of concerns and meets most requirements, but there's a critical bug in the category filtering logic that must be fixed. In src/services/expenses.service.js, the filter callback in the getAll function is missing a return statement. The expression categories.includes(expense.category) evaluates correctly but implicitly returns undefined since arrow functions with curly braces require an explicit return. This causes all expenses to be filtered out when using multiple categories instead of returning matches. The same issue appears in src/services/users.service.js and src/controllers/users.controller.js. Add return before categories.includes(expense.category) in each filter callback to fix this. Once fixed, the filtering will work as intended and your implementation will satisfy all requirements.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +37 to +40

const user = usersService.getById(id);

if (!user) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filter callback doesn't return a value - it evaluates categories.includes(expense.category) but doesn't return it, so the filter always returns falsy. This means filtering by multiple categories as an array will return an empty array instead of matching expenses.

Comment on lines +29 to +31

return user;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filter callback is missing a return statement. The expression categories.includes(expense.category) evaluates but the result isn't returned, causing the filter to always return falsy and empty the results when categories is an array.

Comment on lines +29 to +30
if (Array.isArray(categories)) {
filteredExpenses = filteredExpenses.filter((expense) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filter callback is missing a return statement. The expression categories.includes(expense.category) evaluates correctly but returns undefined (nothing is returned from the arrow function), causing the filter to always fail. This means when categories is an array, all expenses will be filtered out instead of returning matching ones.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Your implementation is approved. The critical category filtering bug in src/services/expenses.service.js has been successfully fixed with the proper return statement, and all core requirements are now met. The application correctly implements 2 collections (users and expenses) with 5 REST endpoints each, proper 404/400 error handling, in-memory data persistence that resets on server restart, and Express app setup without calling listen(). The separation of concerns across routes, controllers, and services is well-structured. Great work on addressing the previous feedback and getting this project across the finish line!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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.

2 participants