Skip to content

solution#514

Open
mForkosh wants to merge 1 commit intomate-academy:masterfrom
mForkosh:develop
Open

solution#514
mForkosh wants to merge 1 commit intomate-academy:masterfrom
mForkosh:develop

Conversation

@mForkosh
Copy link
Copy Markdown

@mForkosh mForkosh commented Apr 7, 2026

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

This requires changes because the core requirement of the task, which was to implement full CRUD functionality for categories, is missing. The submitted code only contains the implementation for users and expenses from the previous task.

To meet the requirements, you need to:

  1. Create a new Category model and its corresponding database table.
  2. Implement a repository, controller, and router to handle the CRUD operations for categories (e.g., at a /categories endpoint).
  3. Update the Expense.model.js to reference a category via a foreign key (e.g., categoryId) instead of using a simple string field.
  4. Register the new category router in src/createServer.js.

Also, please note a smaller issue in src/controllers/expenses.controller.js: res.send(204) should be res.sendStatus(204) to correctly send a response with no body.

The existing code is a good foundation, but the main feature for this task needs to be implemented.


✨ 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 +1 to +30
const { models } = require('../models/models.js');
const Expense = models.Expense;

const getAll = (filterParams = {}) => {
return Expense.findAll({ where: filterParams });
};

const create = (data) => {
return Expense.create(data);
};

const getById = (id) => {
return Expense.findByPk(id);
};

const remove = (id) => {
return Expense.destroy({ where: { id } });
};

const update = (id, data) => {
return Expense.update(data, { where: { id }, returning: true });
};

module.exports = {
getAll,
create,
getById,
remove,
update,
};
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 core requirement of this task is to implement CRUD functionality for categories. This includes creating a Category model, a repository for it, a controller, and router. None of these have been added to the project. The current files only show the implementation for users and expenses.

Comment thread src/createServer.js
app.use(cors(), express.json());

app.use('/users', usersRouter);
app.use('/expenses', expensesRouter);
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 task requires implementing CRUD operations for categories, but the router for the /categories endpoint has not been added to the server.

case 'spentAt':
return isDate(o[k]);
case 'title':
case 'category':
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 task requires implementing a full CRUD for categories. This implies 'category' should be its own resource (with a model, DB table, etc.), not just a string property of an expense. You would then reference it using an ID (e.g., categoryId) and validate that ID here.

return;
}

res.send(204);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using res.send(204) is not the correct way to send a 'No Content' response. This method will send a response with a body containing the text '204'. A 204 response must not have a body. Please use res.sendStatus(204) instead, which correctly sets the status and ensures no body is sent.

Comment on lines +30 to +32
category: {
type: DataTypes.STRING,
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To properly manage categories with full CRUD functionality, they should be a separate entity in the database. Instead of a STRING type for the category name, you should have a categoryId field here that acts as a foreign key to a new Category table. You'll need to create a Category.model.js file for this new entity.

Copy link
Copy Markdown

@brespect brespect left a comment

Choose a reason for hiding this comment

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

Well done!

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