Skip to content

Conversation

@bobtaroh
Copy link
Collaborator

概要

詳細

動作確認

フロントに変更がある場合、画像を添付すること

確認項目

  • 動作確認を実施している
  • issueはPRページ右下のDevelopmentからissueが紐づいている

@gemini-code-assist
Copy link

Summary of Changes

Hello @bobtaroh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、開発環境のセットアッププロセスとサーバーサイドのAPI構造を大幅にリファクタリングすることを目的としています。特に、アプリケーションのセットアップスクリプトをより明確に分離し、VS Codeの設定を改善して開発体験を向上させました。また、サーバーサイドでは、以前のユーザー管理中心のAPIから、旅行プラン、ページ、ブロックという新しいエンティティを中心としたAPIに移行し、関連するCRUD操作、Pydanticスキーマ、およびテストを全面的に再構築しました。これにより、将来の機能拡張が容易になり、コードベースの保守性が向上します。

Highlights

  • 開発環境セットアップの改善: 開発環境のセットアップスクリプトを改善し、アプリケーション固有のセットアップをより明確に分離しました。
  • VS Code設定の強化: VS Codeの設定を更新し、Markdownの自動フォーマット、Pythonの仮想環境管理、mypyによる型チェック、pytestの詳細なテスト実行オプションを強化しました。
  • 開発スクリプトの効率化: package.jsonに、フロントエンドとサーバーサイドのビルド、テスト、リンティング、フォーマット、データベースマイグレーションのための新しいスクリプトを追加し、開発ワークフローを効率化しました。
  • サーバーサイドAPI構造のリファクタリング: サーバーサイドのAPI構造を大幅にリファクタリングし、以前のユーザー管理機能から旅行プラン、ページ、ブロックを中心としたCRUD操作に移行しました。
  • 新しいAPIエンドポイントとテストの導入: 新しいAPIエンドポイントと対応するCRUDロジック、Pydanticスキーマ、およびテストを導入し、旅行プランの作成、取得、更新、削除、およびそれに紐づくページとブロックの管理を可能にしました。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/ci_server.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストは、開発環境のセットアップスクリリプト、VSCode設定、npmスクリプトをリファクタリングし、サーバーサイドのAPIを大幅に再構築するものです。特に、Trip, Page, Blockという新しいモデルに対応するCRUD操作とAPIエンドポイントが追加されています。全体として、開発体験を向上させ、APIの構造を整理するための良い変更です。ただし、1点クリティカルな問題点を指摘しました。新しく追加されたサーバーサイドのコードにおいて、非同期関数(async def)内で同期的なデータベース操作が行われており、これはパフォーマンス上の深刻な問題を引き起こす可能性があります。この問題は複数のファイルにまたがるため、修正方法の詳細は各コメントに記載しましたので、ご確認をお願いします。

Comment on lines 7 to 23
async def create_block(db: Session, block: BlockCreate, page_id: int) -> Block:
"""
ブロックをデータベースに作成する関数

Args:
db (Session): データベースセッション
block (BlockCreate): ブロック作成用のスキーマ
page_id (int): ページのID

Returns:
Block: 作成されたブロック
"""
db_block = Block(**block.model_dump(), page_id=page_id)
db.add(db_block)
db.commit()
db.refresh(db_block)
return db_block

Choose a reason for hiding this comment

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

critical

非同期関数内での同期I/Oブロッキング

現在の実装では、CRUD関数(create_block, find_blocksなど)がasync defで定義されていますが、内部で使用されているSQLAlchemyのSession (db.add, db.commit, db.queryなど)は同期的なブロッキングI/Oです。
FastAPIのasyncエンドポイント内でこれらの同期関数を呼び出すと、イベントループがブロックされ、アプリケーション全体のパフォーマンスが著しく低下する原因となります。これはpages.pytrips.pyのCRUD関数にも共通する問題です。

この問題を解決するには、データベースアクセスが同期的であるため、関連する関数をすべて同期的にする必要があります。

推奨される修正方法は以下の通りです。

  1. server/app/cruds/ ディレクトリ内のすべてのCRUD関数 (blocks.py, pages.py, trips.py) を async def から def に変更してください。
  2. server/app/routers/ ディレクトリ内の、これらのCRUD関数を呼び出しているエンドポイント関数も async def から def に変更し、CRUD関数呼び出し時の await を削除してください。FastAPIは同期的なパスオペレーション関数をスレッドプールで実行するため、イベントループはブロックされません。
  3. server/tests/ ディレクトリ内の関連するテストやfixtureも同様に async から同期的な実装に修正してください(@pytest.mark.asyncioasync def の削除、await の削除など)。

以下にcreate_block関数の修正例を示します。この修正をこのファイル内のすべての関数、および関連する他のファイルにも適用してください。

Suggested change
async def create_block(db: Session, block: BlockCreate, page_id: int) -> Block:
"""
ブロックをデータベースに作成する関数
Args:
db (Session): データベースセッション
block (BlockCreate): ブロック作成用のスキーマ
page_id (int): ページのID
Returns:
Block: 作成されたブロック
"""
db_block = Block(**block.model_dump(), page_id=page_id)
db.add(db_block)
db.commit()
db.refresh(db_block)
return db_block
def create_block(db: Session, block: BlockCreate, page_id: int) -> Block:
"""
ブロックをデータベースに作成する関数
Args:
db (Session): データベースセッション
block (BlockCreate): ブロック作成用のスキーマ
page_id (int): ページのID
Returns:
Block: 作成されたブロック
"""
db_block = Block(**block.model_dump(), page_id=page_id)
db.add(db_block)
db.commit()
db.refresh(db_block)
return db_block

Comment on lines 18 to 20
async def create_block(
page_id: int, block: BlockCreate, db: Session = Depends(get_db_session)
) -> Block:

Choose a reason for hiding this comment

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

critical

非同期関数内での同期I/Oブロッキング

cruds/blocks.pyへのコメントで指摘したように、同期的なDB操作を行うため、このエンドポイントも同期関数(def)として定義する必要があります。FastAPIは同期関数をスレッドプールで実行するため、イベントループをブロックしません。

この修正は、routersディレクトリ内の他のエンドポイント(pages.py, trips.py)にも適用してください。

Suggested change
async def create_block(
page_id: int, block: BlockCreate, db: Session = Depends(get_db_session)
) -> Block:
def create_block(
page_id: int, block: BlockCreate, db: Session = Depends(get_db_session)
) -> Block:

@bobtaroh bobtaroh force-pushed the feature/issue51_refactor-server-test-and-env branch from b35cbc9 to f020d94 Compare December 24, 2025 14:33
@bobtaroh bobtaroh changed the base branch from develop to feature/issue38_add-server-test-system December 24, 2025 14:34
@bobtaroh bobtaroh self-assigned this Dec 24, 2025
@github-actions
Copy link

github-actions bot commented Dec 24, 2025

Visit the preview URL for this PR (updated for commit 9bedd90):

https://tabi-share-8ef6b--pr52-feature-issue51-refa-9lj77khl.web.app

(expires Wed, 31 Dec 2025 14:51:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9f2a87ede127df7673322845e34cf22c1372d720

@bobtaroh
Copy link
Collaborator Author

mypyが型の違いを許してくれるように設定や実装にできないか、調査しよう。

Base automatically changed from feature/issue38_add-server-test-system to develop December 27, 2025 09:01
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.

1 participant