Skip to content

feat: 자산 목록 조회 응답에 main_picture 필드 추가#39

Merged
seaotter316 merged 1 commit intomainfrom
feature/add-main-picture-to-asset-response
Feb 6, 2026
Merged

feat: 자산 목록 조회 응답에 main_picture 필드 추가#39
seaotter316 merged 1 commit intomainfrom
feature/add-main-picture-to-asset-response

Conversation

@swfs0417
Copy link
Collaborator

@swfs0417 swfs0417 commented Feb 6, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a main_picture field to the asset list response so clients can identify an asset’s designated main image.

Changes:

  • Extend AssetResponse schema to include main_picture: Optional[int].
  • Populate main_picture in list_assets_for_club() from the asset’s pictures marked is_main.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
asset_management/app/assets/services.py Adds logic to compute main_picture during asset list mapping.
asset_management/app/assets/schemas.py Adds the main_picture field to the asset response schema.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

location=asset.location,
created_at=asset.created_at,
max_rental_days=asset.max_rental_days,
main_picture=next((p.id for p in asset.pictures if p.is_main), None),
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

asset.pictures access here will lazily load the full Picture rows for each asset (including the BLOB data column) and will also do it per-asset, creating a large N+1 query + memory cost on the list endpoint. Prefer fetching only the main picture id via a single query (e.g., join/correlated subquery) or eager-load a restricted set of columns (e.g., selectinload(...).load_only(Picture.id, Picture.is_main)) so listing assets doesn’t pull image binaries into memory.

Suggested change
main_picture=next((p.id for p in asset.pictures if p.is_main), None),
main_picture=getattr(asset, "main_picture_id", None),

Copilot uses AI. Check for mistakes.
location: Optional[str] = None
created_at: datetime
max_rental_days: Optional[int] = None
main_picture: Optional[int] = None
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This PR adds a new response field (main_picture) but there’s no test asserting it’s present/correct when a main picture exists. Consider extending the existing asset list API test to upload a picture, mark it as main, then verify main_picture equals that picture id (and is null when no main picture is set).

Copilot uses AI. Check for mistakes.
@seaotter316 seaotter316 merged commit f86b5c8 into main Feb 6, 2026
11 checks passed
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