Skip to content

Refector/130 email imgcnt#131

Merged
selnem merged 2 commits into
developfrom
refector/130-email-imgcnt
Jun 16, 2026
Merged

Refector/130 email imgcnt#131
selnem merged 2 commits into
developfrom
refector/130-email-imgcnt

Conversation

@selnem

@selnem selnem commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

🔗 Related Issue

✨ 작업 개요

이슈 핀 생성/수정 시 이미지가 최소 1장 이상 유지되도록 검증을 추가하고, 관리자 전용 민원 신청 이력 검토 API를 추가했습니다.

주요 작업 내용

  • 이슈 핀 생성 시 photospinImages가 최소 1장 이상 필요하도록 검증 추가
  • 이슈 핀 수정 시 기존/신규 이미지를 모두 제거하여 최종 이미지가 0장이 되는 케이스 차단
  • 이미지 필수 누락 에러 코드 PIN_IMAGE_400_4 추가
  • Swagger/OpenAPI 설명에 이미지 최소 1장 필수 조건 반영
  • 관리자용 민원 신청 이력 목록 조회 API 추가
    • GET /complaint-admin/petitions
    • status, limit, offset 지원
  • 관리자용 민원 신청 이력 단건 조회 API 추가
    • GET /complaint-admin/petitions/{petition_id}
  • 민원 검토 응답에 created_at, updated_at, location_region, pin_title 필드 추가
  • 관련 서비스 테스트 추가
    • tests/test_issue_pin_image_required.py
    • tests/test_complaint_petition_review.py

체크리스트

  • Reviewers, Assignees, Labels를 모두 등록했나요?
  • .gitignore 설정을 하였나요?
  • PR 머지 전 반드시 CI가 정상적으로 작동하는지 확인해주세요!

📷 이미지 첨부 (선택)

image image

🧐 집중 리뷰 요청

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.

  • 이슈 핀 수정 시 최종 이미지가 0장이 되는 케이스를 모두 적절히 막고 있는지 확인 부탁드립니다.
  • 관리자 민원 검토 API 응답 필드가 프론트/관리자 화면에서 사용하기에 충분한지 확인 부탁드립니다.
  • status 필터, limit/offset 페이지네이션 동작 방식이 기대한 정책과 맞는지 확인 부탁드립니다.

Test plan

@selnem selnem requested a review from qkwltkwkd1 June 16, 2026 10:34
@selnem selnem self-assigned this Jun 16, 2026
@selnem selnem added ♻️ refactor 기능 변화 없는 코드 리팩터링 ⭐ feat 새로운 기능 labels Jun 16, 2026

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces admin endpoints and services for reviewing complaint petitions, including listing with pagination/filtering and retrieving detailed petition information. It also enforces a requirement that issue pins must have at least one image when created or updated, adding corresponding validation and unit tests. Feedback highlights a potential ValidationError in ComplaintPetitionService if database fields are None, with a suggestion to use default empty strings. Additionally, suggestions were made to improve SQLAlchemy query construction in ComplaintPetitionRepo by chaining nested relationship options more cleanly and applying filters before limit/offset for better readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +563 to +566
if location_department is not None:
location_department_email = location_department.location_department_email
if location_department.department is not None:
department_name = location_department.department.department_name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

데이터베이스에서 location_department_email 또는 department_nameNone일 경우, ComplaintPetitionReviewItemComplaintPetitionApplyResponse 스키마에서 해당 필드들을 필수 문자열(str)로 정의하고 있기 때문에 Pydantic 검증 에러(ValidationError)가 발생할 수 있습니다. 안전한 방어적 프로그래밍을 위해 or ""를 사용하여 None인 경우 빈 문자열로 대체하는 것을 권장합니다.

Suggested change
if location_department is not None:
location_department_email = location_department.location_department_email
if location_department.department is not None:
department_name = location_department.department.department_name
if location_department is not None:
location_department_email = location_department.location_department_email or ""
if location_department.department is not None:
department_name = location_department.department.department_name or ""

Comment on lines +23 to +24
selectinload(ComplaintPetition.location_department).selectinload(LocationDepartment.department),
selectinload(ComplaintPetition.location_department).selectinload(LocationDepartment.location),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

동일한 관계 경로(ComplaintPetition.location_department)에 대해 여러 번 selectinload를 호출하는 대신, options() 메서드를 사용하여 하위 관계들을 한 번에 체이닝하는 것이 더 깔끔하고 SQLAlchemy에서 권장하는 방식입니다.

            selectinload(ComplaintPetition.location_department).options(
                selectinload(LocationDepartment.department),
                selectinload(LocationDepartment.location),
            ),

Comment on lines +78 to +86
list_stmt = (
select(ComplaintPetition)
.options(*self._review_load_options())
.order_by(ComplaintPetition.created_at.desc())
.limit(limit)
.offset(offset)
)
if filters:
list_stmt = list_stmt.where(*filters)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

SQLAlchemy에서 where 필터를 limitoffset 메서드 호출 이후에 적용하는 것은 문법적으로는 허용되지만, 실제 생성되는 SQL의 구조와 일치하지 않아 가독성을 떨어뜨리고 혼란을 줄 수 있습니다. 필터(where)를 먼저 적용한 후 정렬(order_by) 및 페이징(limit, offset)을 적용하는 것이 더 직관적이고 올바른 관례입니다.

        list_stmt = select(ComplaintPetition).options(*self._review_load_options())
        if filters:
            list_stmt = list_stmt.where(*filters)
        list_stmt = (
            list_stmt.order_by(ComplaintPetition.created_at.desc())
            .limit(limit)
            .offset(offset)
        )

@qkwltkwkd1 qkwltkwkd1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

고생하셨습니다!

@selnem selnem merged commit 8a9bd0e into develop Jun 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐ feat 새로운 기능 ♻️ refactor 기능 변화 없는 코드 리팩터링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 이메일 확인용 개발자 api와, 글 생성 및 수정시 이미지 1장이상 남겨놓도록수정

2 participants