Skip to content

Conversation

@hyerinhwang-sailin
Copy link
Collaborator

@hyerinhwang-sailin hyerinhwang-sailin commented Mar 27, 2025

Related issue 🛠

Work Description ✏️

📌 변경 배경

기존에는 유저의 활동 기간(soptDuring)을 계산하는 로직이 여러 곳에서 서로 다른 기준으로 중복 정의되어 있었습니다.
대표적으로 다음 두 방식이 사용되고 있었습니다:

  1. /sopt-log에서 사용하던 방식 (getDuration)
long monthsBetweenGenerations = (currentGeneration - myGeneration) * 6;
...
int monthsSinceStart = currentMonth - startMonth;
return monthsBetweenGenerations + monthsSinceStart;
  • 세대 간 간격을 6개월로 가정하고 계산
  • now() 기준으로 현재 세대가 시작된 후 경과 개월 수를 단순 계산
  • 실제 날짜가 아닌 근사치 기반 계산이기 때문에 오차 발생
  1. /home에서 사용하던 방식 (ActivityDurationCalculator)
LocalDate startDate = calculateStartDate(); // generation 기준 실제 날짜
Period period = Period.between(startDate, CurrentDate.now);
return period.getYears() * 12 + period.getMonths() + 1;
  • SOPT 시작 연도(2007년)를 기준으로 각 generation의 시작 날짜 계산
  • 실제 날짜 차이를 기준으로 활동 개월 수를 구함
  • 정확한 기준에 따라 계산되며, 통일된 기준으로 재사용 가능

✅ 주요 변경 사항

  1. ActivityDurationCalculator 유틸화 (common.utils)
  • 기존 인스턴스 기반 → 완전 정적 유틸 클래스 (final + static method)
  • 사용 방식:
int duration = ActivityDurationCalculator.calculate(List<Long> generations);
  1. /sopt-log 계산 방식 교체
  • authFacade.getDuration(...) → ActivityDurationCalculator.calculate(...)로 변경
  • PlaygroundProfile에서 getAllActivities().stream().map(...).toList()로 generation 리스트 추출
  1. /home API는 기존 그대로 유지, 계산 기준 통일됨
    동일한 유틸 클래스 사용으로 /sopt-log와 /home의 활동 개월 수 일치

🛠 기타 수정 사항

  • Long == Long 비교 로직을 .equals(...)로 변경하여 null 안전 및 정확성 확보:
Boolean isActive = playgroundProfile.getLatestActivity().getGeneration().equals(generation);

Trouble Shooting ⚽️

Related ScreenShot 📷

Uncompleted Tasks 😅

To Reviewers 📢

local에서 임의 테스트는 진행했으나 dev 테스트가 추가로 필요해 머지 후 테스트하고 결과 공유하겠습니다!
/sopt-log
image
/description
image
일치하는 것 확인했습니다!
정상 작동 확인 시 기존에 /sopt-log 계산 방식인 getDuration()은 사용처가 없어지므로 삭제하도록 하겠습니다!

@hyerinhwang-sailin hyerinhwang-sailin linked an issue Mar 27, 2025 that may be closed by this pull request
1 task
@height
Copy link

height bot commented Mar 27, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@hyerinhwang-sailin hyerinhwang-sailin self-assigned this Mar 27, 2025
@hyerinhwang-sailin hyerinhwang-sailin added 🔨 Refactor 코드 개선 🛠️ BugFix 버그 해결 labels Mar 27, 2025
@hyerinhwang-sailin hyerinhwang-sailin merged commit 89f7fca into dev Mar 27, 2025
1 check passed
@geniusYoo
Copy link
Contributor

래퍼 객체 equals와 유틸 클래스를 static final 화 한 것이 좋네요 :) 고생하셨습니다 !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ BugFix 버그 해결 🔨 Refactor 코드 개선 size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] 홈 솝트로그 활동개월수 불일치 이슈 해결

2 participants