Skip to content

fix(payment): paginate pending requests#48

Open
popeye0618 wants to merge 1 commit into
mainfrom
fix/admin-payment-pagination
Open

fix(payment): paginate pending requests#48
popeye0618 wants to merge 1 commit into
mainfrom
fix/admin-payment-pagination

Conversation

@popeye0618
Copy link
Copy Markdown
Member

개요

관리자 pending 결제 요청 목록이 전체 List를 반환하던 병목을 제거하고, Pageable 기반 PagingResponse로 응답하도록 변경했습니다.

Closes #47

@codex

변경 사항

  • GET /api/v1/admin/payment/requestsPageable을 적용하고 기본값을 size=20, sort=requestedAt,DESC로 설정했습니다.
  • 서비스에서 페이지 크기를 최대 100으로 제한해 요청당 조회 상한을 보장합니다.
  • repository 조회를 Page<Order> 반환으로 변경했습니다.
  • 페이지 내 orderItems lazy collection 로딩 비용을 줄이기 위해 @BatchSize(size = 100)을 적용했습니다.
  • 응답 변경에 맞춰 Notion Comatching > API 명세서 > 자체 결제의 관리자 대기 주문 목록 조회 명세를 갱신했습니다.

테스트

  • 테스트를 실행했습니다. ./gradlew :item-service:test
  • 테스트를 실행했습니다. ./gradlew test
  • 관련 수동 검증을 완료했습니다. Notion API 명세 갱신
  • 테스트가 필요 없는 변경입니다.

체크리스트

  • 브랜치명이 규칙을 따릅니다.
  • 커밋 메시지가 컨벤션을 따릅니다.
  • 이슈와 PR이 연결되어 있습니다.
  • 작업 완료 후 merge 가능한 상태입니다.

스크린샷 / 참고 자료

  • 성능 리뷰 Finding 4: admin pending 결제 요청 목록의 무제한 List 반환 병목

Copy link
Copy Markdown

@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

This pull request implements pagination for pending purchase requests across the controller, service, and repository layers. Key changes include updating the repository to support paged queries, introducing a bounded page size logic in the service implementation, and adding corresponding unit tests. Feedback focuses on externalizing configuration constants via @ConfigurationProperties, optimizing performance by applying @transactional(readOnly = true) to the read-only service method, and improving robustness by ensuring a minimum page size of 1 to prevent potential runtime exceptions.

public class AdminPaymentServiceImpl implements AdminPaymentService {

private static final String EXPIRE_REASON = "AUTO_EXPIRED_BEFORE_ADMIN_DECISION";
private static final int MAX_PENDING_REQUEST_PAGE_SIZE = 100;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

MAX_PENDING_REQUEST_PAGE_SIZE와 같은 설정 값은 코드 내 상수로 관리하기보다 @ConfigurationProperties를 통해 외부 설정 파일(yml/properties)에서 관리하는 것을 권장합니다. 이를 통해 운영 환경에서 코드 수정 없이 상한선을 조정할 수 있어 유연성이 높아집니다.

References
  1. 설정 값은 @value 남용 대신 @ConfigurationProperties 사용을 권장합니다. (link)

@@ -40,11 +45,25 @@ public class AdminPaymentServiceImpl implements AdminPaymentService {
private static final int PURCHASED_ITEM_EXPIRE_DAYS = 36500;

@Override
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

getPendingRequests 메서드는 단순 조회 로직이므로, 성능 최적화(스냅샷 저장 방지 등)를 위해 @Transactional(readOnly = true)를 명시하는 것이 좋습니다. 현재 클래스 레벨에 @Transactional이 선언되어 있어 기본적으로 쓰기 트랜잭션이 적용되고 있습니다.

	@Transactional(readOnly = true)
	@Override
References
  1. 조회 전용 로직에는 readOnly = true가 명시되어 있는지 검토합니다. (link)

return PageRequest.of(0, MAX_PENDING_REQUEST_PAGE_SIZE, DEFAULT_PENDING_REQUEST_SORT);
}

int pageSize = Math.min(pageable.getPageSize(), MAX_PENDING_REQUEST_PAGE_SIZE);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

pageable.getPageSize()가 1보다 작은 경우(예: 0) PageRequest.of 호출 시 IllegalArgumentException이 발생할 수 있습니다. 최소 크기(1)를 보장하도록 Math.max(1, ...)를 추가하여 안정성을 높이는 것을 권장합니다.

Suggested change
int pageSize = Math.min(pageable.getPageSize(), MAX_PENDING_REQUEST_PAGE_SIZE);
int pageSize = Math.max(1, Math.min(pageable.getPageSize(), MAX_PENDING_REQUEST_PAGE_SIZE));

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.

fix(payment): paginate pending payment requests

1 participant