-
Notifications
You must be signed in to change notification settings - Fork 2
[Feat] 위치기반 리마인드 알림 시 해당 일기와 해당 일기 기준 반경 500m 내의 일기들에 한달(30일) 쿨타임 부여 #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @Jinho622, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 위치 기반 리마인드 알림 시스템에 쿨타임 기능을 도입합니다. 특정 일기에 대한 알림이 발송되면, 해당 일기 및 주변 500m 반경 내의 일기들에 30일간의 쿨타임이 적용되어 중복 알림을 방지합니다. 이 쿨타임은 매일 자정에 자동으로 감소하며, 쿨타임이 남아있는 일기는 알림 대상에서 제외됩니다. 이는 사용자 경험을 개선하고 알림의 효율성을 높이는 것을 목표로 합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 introduces a memory diary alarm cool-down feature by adding a memoryDiaryAlarmCoolTime field to the Diaries entity and an associated update method. The DiaryRepository is modified to exclude diaries with active cool-down periods from being considered for near diary candidates. A scheduled task is added to AlarmCommandServiceImpl to decrement the cool-down time for all diaries daily. In DiaryQueryServiceImpl, logic is implemented to set a 30-day cool-down for diaries within a 500m radius of a 'remind diary' once it's found. Review comments suggest optimizing the daily cool-down decrement using a bulk database update to avoid performance issues, ensuring safe access to Optional values, correcting the calculation for the square search area to accurately cover a 500m radius, updating an incorrect comment for a constant, replacing System.out.println with proper logging, removing a personal comment, and renaming a misleading variable (nearestDiary to diariesInRadius) for clarity.
| List<Diaries> diariesList = diaryRepository.findAll(); | ||
| for (Diaries diary : diariesList) { | ||
| int currentCoolTime = diary.getMemoryDiaryAlarmCoolTime(); | ||
| if (currentCoolTime > 0) { | ||
| diary.updateMemoryDiaryAlarmCoolTime(currentCoolTime - 1); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 구현은 findAll()을 사용하여 모든 일기 데이터를 메모리로 불러온 후, 하나씩 쿨타임을 감소시키고 있습니다. 일기 데이터가 많아질 경우 심각한 성능 저하 및 OutOfMemoryError를 유발할 수 있습니다.
데이터베이스에서 직접 업데이트를 수행하는 것이 훨씬 효율적입니다. DiaryRepository에 아래와 같이 @Modifying 어노테이션을 사용한 벌크 업데이트 메서드를 추가하고, 이 메서드를 호출하도록 수정하는 것을 강력히 권장합니다.
DiaryRepository.java에 추가할 메서드 예시:
@Modifying
@Query("UPDATE Diaries d SET d.memoryDiaryAlarmCoolTime = d.memoryDiaryAlarmCoolTime - 1 WHERE d.memoryDiaryAlarmCoolTime > 0")
void decreaseCoolTimeOnMemoryDiaries();이후 이 메서드 본문을 diaryRepository.decreaseCoolTimeOnMemoryDiaries(); 호출로 변경해주세요.
| System.out.println("nearestDiaries real Candidates: " + nearestDiary.get().getId()); | ||
|
|
||
| // 반환한 일기(nearestDiary) 주변 500m반경 내의 일기들의 위치기반 추억 알림 쿨타임을 한달(30일)로 설정 | ||
| setMemoryDiaryAlarmCoolTime(userId, nearestDiary.get(), 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Decoded decoded = tryDecode(currentDiary, userId); | ||
| Double currentLatitude = decoded.lat(); | ||
| Double currentLongitude = decoded.lng(); | ||
| List<Pt> square = buildSquare(currentLatitude, currentLongitude, 600.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
500m 반경 내의 일기를 찾기 위해 600m 변의 정사각형을 사용하는 것은 부정확합니다. 이 정사각형은 중심에서 모서리까지의 거리가 약 424m(300 * sqrt(2))이므로, 424m에서 500m 사이의 대각선 방향에 있는 일기들을 놓칠 수 있습니다.
500m 반경을 완전히 포함하려면 정사각형의 한 변의 길이는 최소 1000m(2 * 500m)가 되어야 합니다. 상수를 사용하여 2.0 * MEMORY_DIARY_COOL_TIME_AREA_RANGE로 설정하는 것이 더 명확하고 유지보수에 용이합니다.
| List<Pt> square = buildSquare(currentLatitude, currentLongitude, 600.0); | |
| List<Pt> square = buildSquare(currentLatitude, currentLongitude, 2.0 * MEMORY_DIARY_COOL_TIME_AREA_RANGE); |
| private static final int SEARCH_RANGE = 100; // 검색 범위 설정 (100m) | ||
| private final GeometryFactory geometryFactory; | ||
| private final EnvelopeCryptoService envelopeCryptoService; | ||
| private static final int MEMORY_DIARY_COOL_TIME_AREA_RANGE = 500; // 검색 범위 설정 (100m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for (Diaries diary : nearDiariesCandidates) { | ||
| System.out.println("nearDiariesCandidates id: " + diary.getId()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| // 검색 범위(정사각형) 내 복호화를 진행하고, 실제로 일기 위도 경도에서 100m 원 안에 있는 일기 중 가장 최신 일기 반환 | ||
| // 영 이상하면 getDate -> getCreatedAt으로 수정 (마지막줄) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| // 검색 범위(정사각형) 내 복호화를 진행하고, 실제로 일기 위도 경도에서 100m 원 안에 있는 일기 중 가장 최신 일기 반환 | ||
| // 영 이상하면 getDate -> getCreatedAt으로 수정 (마지막줄) | ||
| List<Diaries> nearestDiary = nearDiariesCandidates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- AlarmCommandServiceImpl클래스에서 Diaries테이블 모든 데이터의 쿨타임 컬럼(memory_diary_alarm_cool_time)의 값 감소시키는 방식 변경함. 1. 기존방식: findAll()을 사용하여 모든 일기 데이터를 메모리로 불러온 후, 하나씩 쿨타임을 감소 2. 변경 방식: DiaryRepository 클래스에서 JPQL 벌크 업데이트(@Modifying + UPDATE 쿼리)로 memory_diary_alarm_cool_time > 0 인 데이터만 일괄적으로 1 감소 처리 - 변경 이유: 전체 데이터 조회/개별 업데이트(N회)로 인한 성능 저하 및 불필요한 DB 부하 개선 - 기대 효과: UPDATE 1회로 처리되어 네트워크/메모리 사용량 감소, 처리 시간 단축
#️⃣연관된 이슈
📝작업 내용
🔎코드 설명
💬고민사항 및 리뷰 요구사항 (Optional)
비고 (Optional)