diff --git a/troubleshooting/250926_happybell80_quote_rotation_improvement.md b/troubleshooting/250926_happybell80_quote_rotation_improvement.md new file mode 100644 index 0000000..85678a0 --- /dev/null +++ b/troubleshooting/250926_happybell80_quote_rotation_improvement.md @@ -0,0 +1,55 @@ +# 명언 로테이션 개선 + +## 날짜: 2025-09-26 +## 작성자: happybell80 +## 관련 서비스: skill_news +## 상태: 개선 필요 + +--- + +## 1. 현재 상황 + +### 파일 위치 +- 코드: `/home/happybell80/ivada_project/skill_news/app/services/naver_startup_news_service.py` +- 데이터: `/home/happybell80/ivada_project/skill_news/app/data/slack_messages.md` + +### 현재 구현 (라인 96-116) +```python +def _get_random_messages(self) -> Tuple[str, str, Tuple[str, str, str]]: + """랜덤 오프닝/클로징/명언 메시지 선택""" + # 라인 111: random.choice(openings) + # 라인 113: random.choice(closings) + # 라인 116: random.choice(quotes) +``` + +### 문제점 +- 완전 랜덤 선택으로 같은 명언이 연속 반복될 수 있음 +- 20개 오프닝, 20개 클로징, 명언 개수는 로더에서 로깅됨 (라인 88) +- 로테이션 순서나 사용 기록 추적 없음 +- 환경변수(HEADLINES_OPENER/CLOSER) 설정 시 랜덤 선택 건너뜀 (라인 105-107) + +--- + +## 2. 개선 방안 + +### 로테이션 방식 (날짜 기반) +- 오늘 날짜를 기준으로 인덱스 계산 +- 인덱스 = (오늘의 일수) % (명언 개수) +- DB 수정 불필요, 코드만 변경 + +### 구현 필요사항 +1. _get_random_messages() 메서드 수정 +2. random.choice() 대신 날짜 기반 인덱스 사용 + ```python + from datetime import datetime + today = datetime.now().timetuple().tm_yday # 1-365 + opener = openings[today % len(openings)] if openings else default_opener + closer = closings[today % len(closings)] if closings else default_closer + quote = quotes[today % len(quotes)] if quotes else default_quote + ``` +3. 환경변수 우선순위 유지 (설정 시 로테이션 비활성) + +--- + +## 3. 기한 +- 1일 (2025-09-27까지) \ No newline at end of file