Skip to content

Solution#656

Open
JustVov4uk wants to merge 2 commits into
mate-academy:mainfrom
JustVov4uk:develop
Open

Solution#656
JustVov4uk wants to merge 2 commits into
mate-academy:mainfrom
JustVov4uk:develop

Conversation

@JustVov4uk
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 mostly solid, but two critical issues prevent approval. First, the database tables are never created—CHECKLIST ITEM #17 explicitly requires calling Base.metadata.create_all(bind=engine) in main.py before the app starts, without which you'll get 'no such table' errors at runtime. Second, the GET /books/ endpoint is missing the author_id query parameter required by CHECKLIST ITEM #6 for filtering books by author. While crud.py has the functionality implemented, the FastAPI endpoint doesn't expose it to users. Add author_id: int = None as a query parameter to read_books and pass it through to crud.get_books(). Once these two issues are addressed, your solution should be complete.


✨ 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 database.py

engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing table creation. The task requirement #17 explicitly states to 'Create database tables using the SQLAlchemy models'. This line should be added to initialize the database on app startup.

Comment thread main.py Outdated
Comment on lines +37 to +39
@app.get("/books/", response_model=List[BookRead])
def read_books(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)):
return crud.get_books(db, skip=skip, limit=limit)
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 read_books endpoint is missing the author_id query parameter. According to checklist item #6, you need to filter books by author ID. Add author_id: int = None as a query parameter and pass it to crud.get_books.

Comment thread main.py Outdated

@app.get("/books/", response_model=List[BookRead])
def read_books(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)):
return crud.get_books(db, skip=skip, limit=limit)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing database table creation. The task requires creating database tables using the SQLAlchemy models (checklist item #17). Add from database import Base, engine and call Base.metadata.create_all(bind=engine) before the app runs, typically at module level or using a startup event.

Comment thread .gitignore
database.db
database.py
.idea

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing table creation: The task requires creating database tables using SQLAlchemy models (checklist item #17), but Base.metadata.create_all(bind=engine) is never called. Add this line to create the tables when the app starts.

Comment thread crud.py
@@ -0,0 +1,41 @@
from sqlalchemy import select
from models import Author, Book
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing file: models.py is not provided but is required. The task specification explicitly requires this file for CHECKLIST ITEMS #11-#26. Line 2 of crud.py imports from this file: from models import Author, Book

Comment thread crud.py
from schemas import AuthorCreate, BookCreate


def get_author(db, 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.

Missing file: schemas.py is not provided but is required. The task specification explicitly requires this file (CHECKLIST ITEM #14). Line 6 of main.py imports from this file: from schemas import AuthorRead, AuthorCreate, BookCreate, BookRead

Comment thread crud.py
Comment on lines +37 to +39
)
db.add(db_book)
db.commit()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing feature: This endpoint does not support filtering books by author ID as required by CHECKLIST ITEM #6. The function should accept an optional author_id: int = None query parameter and pass it to crud.get_books().

Comment thread schemas.py

class AuthorCreate(BaseModel):
name: str
bio: str
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing table creation: The task requires creating database tables using SQLAlchemy models (checklist item #17). Add Base.metadata.create_all(bind=engine) to create the tables when the application starts.

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

The implementation is complete and fully satisfies all task requirements. Both critical issues from the previous review have been successfully resolved: (1) database tables are now created at startup via Base.metadata.create_all(bind=engine) in main.py, and (2) the GET /books/ endpoint properly exposes the author_id query parameter for filtering books by author. All five required files are present with correct structure, SQLAlchemy models include all specified fields with proper relationships, Pydantic schemas validate input/output correctly, CRUD functions are implemented, and all API endpoints (POST/GET /authors/, GET /authors/{id}, POST/GET /books/) function as specified with pagination support. Your solution is approved and ready for use.


✨ 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