Skip to content

Created all files and realize app#650

Open
shafran-andriy wants to merge 15 commits into
mate-academy:mainfrom
shafran-andriy:main
Open

Created all files and realize app#650
shafran-andriy wants to merge 15 commits into
mate-academy:mainfrom
shafran-andriy:main

Conversation

@shafran-andriy
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 has critical issues that must be fixed:

  1. Pagination is not implemented — In crud.py, both get_all_authors() and get_books() accept skip and limit parameters but never use them. The queries call .all() directly, returning all records instead of paginated results. You need to add .offset(skip).limit(limit) before .all() to make pagination work.

  2. Broken Alembic migration chain — Two migration files (19a43ef19f34 and cafdeb00731a) both have down_revision = None. Only ONE migration can be the initial migration (head). Additionally, 19a43ef19f34_initial_migration.py is completely empty (just pass statements), so it should be deleted entirely. Keep cafdeb00731a as your single initial migration.

  3. Function signature mismatch — In alembic/versions/cafdeb00731a_initial_migration.py, the get_all_authors function only accepts db, but the /authors/ endpoint calls it with skip and limit arguments. This will cause a runtime error. The function needs to accept and use these pagination parameters.

These issues break core functionality (pagination silently failing, migration chain broken) and must be addressed before approval.


✨ 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 alembic/env.py
Comment on lines +7 to +17

from db.database import Base, SQLALCHEMY_DATABASE_URL
# import models so they are registered on Base.metadata for autogenerate
import db.models # noqa: F401

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# ensure alembic uses the same database URL as the application
config.set_main_option("sqlalchemy.url", SQLALCHEMY_DATABASE_URL)

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 skip and limit parameters are accepted but never used. get_all_authors() returns all authors without pagination. Consider adding .offset(skip).limit(limit) to implement the pagination that the endpoint declares.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread alembic/env.py
Comment on lines +51 to +60
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)

with context.begin_transaction():
context.run_migrations()


def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
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 skip and limit parameters are accepted but never used. get_books() returns all books without pagination. Consider adding .offset(skip).limit(limit) to implement the pagination that the endpoint declares.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread alembic/env.py
Comment on lines +20 to +31
if config.config_file_name is not None:
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This migration file has an empty upgrade() function with only pass. It appears to be an incomplete/placeholder migration that should either be removed or contain actual schema changes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread alembic/env.py Outdated
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# ensure alembic uses the same database URL as the application
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This migration lacks a proper down_revision to link it in the migration chain. It should reference the previous migration (e.g., down_revision = '19a43ef19f34') to maintain proper Alembic migration ordering.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +7 to +9
"""
from typing import Sequence, Union

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 get_all_authors function signature only accepts db parameter, but the /authors/ endpoint calls it with skip and limit arguments. The function needs to accept these parameters and apply them using .offset(skip).limit(limit).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread crud.py
Comment on lines +14 to +16


def get_author_by_name(db: Session, name: 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.

Both migration files have down_revision = None, which means they are both treated as initial migrations. This creates a conflict in the migration chain since only one migration can be the starting point. One of them should reference the other via down_revision.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread crud.py
Comment on lines +20 to +24
def get_authors_list(
db: Session,
name: str | None = None,
bio: str | None = None,
):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This migration is empty (just pass statements). If this is intentional as a placeholder, that's fine, but if the intention was to create tables, this migration doesn't do anything. The tables are created in cafdeb00731a_initial_migration.py instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread crud.py Outdated
Comment on lines +8 to +9
def get_all_authors(db: Session):
return db.query(models.Author).all()
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 function accepts skip and limit parameters for pagination as per the task requirements, but they are not used. The query uses .all() which returns all results, ignoring pagination entirely. Consider using .offset(skip).limit(limit) to implement proper pagination.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread crud.py Outdated
Comment on lines +51 to +58

def get_books(db: Session, author_id: int | None = None):
queryset = db.query(models.Book)

if author_id is not None:
queryset = queryset.filter(models.Book.author_id == author_id)

return queryset.all()
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 function accepts skip and limit parameters for pagination as per the task requirements, but they are not used. The query uses .all() which returns all results, ignoring pagination. Consider using .offset(skip).limit(limit) to implement proper pagination.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

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 Library Management API implementation is complete and meets all task requirements. The three critical issues from the previous review have been successfully resolved: pagination is now correctly implemented using ".offset(skip).limit(limit).all()" in both get_all_authors() and get_books() functions, the empty migration file has been deleted, and the Alembic migration chain properly contains only the single initial migration cafdeb00731a_initial_migration.py with down_revision = None. All core requirements are satisfied: FastAPI framework, SQLAlchemy ORM with SQLite, proper Author/Book models with bidirectional relationships, Pydantic schemas for validation, CRUD operations with pagination support, and all required API endpoints. The codebase is functional 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

Comment thread crud.py Outdated
db.add(db_book)
db.commit()
db.refresh(db_book)
return db_book No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add new empty line please

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added

Comment thread library_catalog.db Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove library_catalog.db from the PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread main.py Outdated
Comment on lines +9 to +10

# Створюємо таблиці в БД на основі SQLAlchemy моделей
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It’s better to write all comments in English.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed

Comment thread test_main.http Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please remove this file from the PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Comment thread main.py Outdated
Comment on lines +91 to +92
limit=limit,
) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add new empty line

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added

@shafran-andriy shafran-andriy requested a review from vsmutok May 14, 2026 16:58
Copy link
Copy Markdown

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

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

Great!

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