Skip to content

Develop - #118

Merged
jaebeom79 merged 2 commits into
mainfrom
develop
Jun 1, 2026
Merged

Develop#118
jaebeom79 merged 2 commits into
mainfrom
develop

Conversation

@jaebeom79

Copy link
Copy Markdown
Contributor

📢 기능 설명

필요시 실행결과 스크린샷 첨부

연결된 issue

연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #{이슈넘버}

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 이슈넘버를 적었는가?

@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 refactors the nearby store search to utilize PostGIS GIST indexing instead of manual bounding box calculations, removes a duplicate B-tree index from the migration script, limits the query size in getStoresInBounds, and adds a Grafana panel for Kafka message throughput. The review feedback highlights a critical issue where the location field's non-insertable/non-updatable configuration in the Store entity could lead to NULL values and missing search results for new stores. Additionally, it suggests safeguarding PageRequest creation against values less than 1 for both size and limit parameters to prevent runtime exceptions.

latitude, longitude,
latitude - deltaLat, latitude + deltaLat,
longitude - deltaLng, longitude + deltaLng,
return storeRepository.findNearbyWithGist(

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.

high

현재 Store 엔티티(Store.java 50-51라인)를 보면 location 필드가 @Column(columnDefinition = "geography(Point, 4326)", insertable = false, updatable = false)로 설정되어 있어, 애플리케이션 단에서 신규 매장을 등록할 때 location 값이 저장되지 않고 NULL로 입력됩니다.\n\n만약 PostgreSQL DB 상에 latitudelongitude 변경 시 location을 자동으로 업데이트해주는 DB Trigger가 별도로 존재하지 않는다면, 신규 등록된 매장은 locationNULL이 되어 findNearbyWithGist 검색 결과에서 누락되는 문제가 발생할 수 있습니다.\n\n해결 방안:\n1. DB 마이그레이션 스크립트에 latitude/longitude 삽입/수정 시 location을 자동 갱신하는 Trigger를 추가합니다.\n2. 또는 Store 엔티티의 location 필드를 insertable = true, updatable = true로 변경하고, 매장 생성/수정 비즈니스 로직에서 GeometryFactory를 이용해 Point 객체를 직접 생성하여 저장하도록 수정합니다.

// 내 주변 매장 (PostGIS GIST 인덱스 + ST_DWithin + KNN 거리 정렬)
@Transactional(readOnly = true)
public List<StoreListResponse> getNearbyStores(double latitude, double longitude, int page, int size) {
int limitedSize = Math.min(size, 100);

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

요청된 size가 1 미만일 경우, PageRequest.of() 메서드 호출 시 IllegalArgumentException이 발생할 수 있습니다. 최소 1 이상의 값을 가지도록 안전하게 제한하는 것이 좋습니다.

Suggested change
int limitedSize = Math.min(size, 100);
int limitedSize = Math.max(1, Math.min(size, 100));

public List<StoreListResponse> getStoresInBounds(
double minLat, double maxLat, double minLng, double maxLng,
Double centerLat, Double centerLng, int limit) {
int limitedLimit = Math.min(limit, 100);

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

전달된 limit 값이 1 미만일 경우, PageRequest.of(0, limitedLimit) 호출 시 IllegalArgumentException이 발생할 수 있습니다. 최소 1 이상의 값을 가지도록 안전하게 제한하는 것이 좋습니다.

Suggested change
int limitedLimit = Math.min(limit, 100);
int limitedLimit = Math.max(1, Math.min(limit, 100));

@jaebeom79
jaebeom79 merged commit 65a9592 into main Jun 1, 2026
1 check 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.

1 participant