Skip to content

Initial commit#592

Open
Taras-Ivashchuk wants to merge 2 commits intomate-academy:mainfrom
Taras-Ivashchuk:develop
Open

Initial commit#592
Taras-Ivashchuk wants to merge 2 commits intomate-academy:mainfrom
Taras-Ivashchuk:develop

Conversation

@Taras-Ivashchuk
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

This is a great submission with a well-organized structure and functional API endpoints. However, changes are needed because a core requirement from the task description was missed.

The application needs to create the database tables from the SQLAlchemy models when it starts up. This logic is currently missing from main.py. You can implement this by importing Base from models and engine from database, and then calling Base.metadata.create_all(bind=engine) before the app runs.

Additionally, here are a couple of minor suggestions for improvement:

  • In crud.py, the type hint for author_id in get_all_books should be int | None to accurately reflect that it can be None.
  • There's a small typo in schemas.py: AutorNestedSchema should be AuthorNestedSchema.

Once you've added the table creation logic, this will be ready for approval. Keep up the great work!


✨ 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 thread crud.py Outdated
db: Session,
to_skip: int,
to_limit: int,
author_id: int
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 type hint for author_id is int, but it can receive None from the endpoint in main.py. To make the type hint accurate, you should indicate that it can also be None. You can use Optional[int] from the typing module or int | None (for Python 3.10+).

Comment thread main.py
)
from database import get_db

app = FastAPI()
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 requirements state that you should create the database tables from the SQLAlchemy models within the main.py file. This is typically done at application startup. You're missing the call to Base.metadata.create_all(bind=engine) here. You would need to import Base from models and engine from database to do this.

Comment thread schemas.py Outdated
from pydantic import BaseModel, Field, ConfigDict


class AutorNestedSchema(BaseModel):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a small typo in the class name. It seems it should be AuthorNestedSchema to be consistent with the other class names like AuthorReadSchema and AuthorCreateSchema.

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

Excellent work on this iteration! I am approving your solution. You've successfully addressed all the previous feedback, especially the critical fix to create the database tables on startup. Your implementation of FastAPI, SQLAlchemy, and Pydantic is solid, and the overall application structure is clean and correct. All requirements have been met. Well done!


✨ 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