Skip to content

Conversation

@Dockerel
Copy link
Contributor

@Dockerel Dockerel commented Sep 4, 2025

#️⃣ 연관된 이슈

📚 배경

초기 화면에서 사용자의 위치로부터 가까운 순으로 요청을 보여주는 기능이 필요합니다.

📝 작업 내용

  • 모든 요청을 받아와 위도 경도 기준 유클리드 제곱거리로 정렬하였습니다.
  • 원래는 위도 경도를 고려한 하버사인 거리를 사용하여야 정확한 거리가 나오지만 캠퍼스 수준(수백 m~수 km) 범위에선 유클리드 제곱거리로도 충분하다고 합니다.
  • 또한 연산량을 고려하여 단순한 유클리드 제곱거리 방식을 선택하였습니다.
  • 기존에 생각한 IN 절에 대해 cellId 인덱스를 추가하여 보았으나 쿼리 플랜 분석 결과 옵티마이저가 인덱스를 타지 못하여 인덱스는 적용하지 않았습니다.
  • 아마 cellId의 카디널리티가 이벤트에 비해 너무 낮아 그냥 풀 테이블 스캔을 해버리는 것 같습니다.

📸 스크린샷

x

💬 리뷰 요구사항

  • 현재는 크게 성능이 좋지 않습니다. 임의의 요청 1000건에 대해 약 1~2초의 시간이 소요됩니다.
  • 하지만 초기 버전이라 더 적은 건수의 요청이 있을거라 생각했고, 또한 네이버 지도의 경우에도 확인해보니 주변 식당 검색 등이 대략 1초 이상 걸리는 것을 확인하여 일단 베타버전 느낌으로 커밋하기로 하였습니다.
  • 추후 hibernate-spatial 로 공간 인덱싱 방식을 적용하여 개선해볼 예정입니다. MySQL에도 해당 방식을 적용할 수 있다는 것 같은데, 굉장히 큰 변경이 예상될 것 같아 일단 해당 방식으로 커밋하게 되었습니다.

✏ Git Close

close #26

@Dockerel Dockerel requested a review from GitJIHO September 4, 2025 07:03
@Dockerel Dockerel self-assigned this Sep 4, 2025
@Dockerel Dockerel added the ✨ Feature 새로운 기능 추가 및 구현하는 경우 label Sep 4, 2025
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

📊 Code Coverage Report

Overall Project 74.38% -0.29% 🍏
Files changed 95.36% 🍏

File Coverage
S2Converter.java 100% 🍏
DdipMapper.java 100% 🍏
DdipEventRepositoryImpl.java 99.1% -0.9% 🍏
LocationService.java 93.42% -2.3% 🍏
S2Constants.java 50% -50%

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Test Results

209 tests   209 ✅  6s ⏱️
 37 suites    0 💤
 37 files      0 ❌

Results for commit 6de7b67.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@GitJIHO GitJIHO left a comment

Choose a reason for hiding this comment

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

트레이드오프를 고려한 적절한 판단인 것 같습니다 👍 고생하셨습니다!
domain필드 추가에 관한 수정 하나만 부탁드립니다 !

import java.time.Instant;
import java.util.UUID;

public abstract class DdipEventFixture {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixture 만들어두는거 좋네요 👍

Comment on lines +47 to +50
@Column(nullable = false)
@Setter
private String cellId;

Copy link
Contributor

Choose a reason for hiding this comment

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

생각해보니 notion에는 ddipEvent 엔티티 필드에 cellId가 정의되어 있지 않았네요
정규화가 되어있던건지,, 관련해서 한번 어떤식으로 현재 프론트 fakeRepository의 비즈니스 로직이 구현되어있는지 이야기해보면 좋을 것 같습니다
entity의 필드가 변경되면 노션의 필드도 변경하는게 연동에 좋을 것 같아 그렇습니다 !

Copy link
Contributor

Choose a reason for hiding this comment

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

컨트롤러단에서 ddipEvent를 생성했을 때 리턴값으로 ddipEvent 도메인을 기반으로 한 dto Json으로 변환해서 제공하기 때문에 cellId에 대한 Mapper에서 toDomain 부분에도 cellId 관련 로직과 DdipEvent 도메인 자체에도 cellId 필드가 있어야 할 것 같습니다.
추후 cellId를 활용한 타 비즈니스 로직이 필요할 때도 현재 domain과 entity가 나뉘어져 있기 때문에 domain단에도 필드가 정의되어 있어야 DDD를 활용가능 할 것 같네요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하 넵! 수정하겠습니다.

@Dockerel Dockerel merged commit f3cc7bb into main Sep 4, 2025
2 checks passed
@Dockerel Dockerel deleted the Feat/issue-#26 branch September 4, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능 추가 및 구현하는 경우

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: 특정 좌표 기준 거리순으로 띱 이벤트 반환 기능

3 participants