From 981606c6a6d0f2646bd9b0cc5cf65de1856bec85 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Fri, 26 Sep 2025 10:40:38 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=EB=AA=85=EC=96=B8=20=EB=A1=9C=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EA=B0=9C=EC=84=A0=20=EB=B0=A9=EC=95=88=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 날짜 기반 로테이션으로 방향 변경 - DB 불필요, 코드 수정만으로 구현 가능 - 환경변수 우선순위 및 구현 세부사항 추가 🤖 Generated with Claude Code Co-Authored-By: Claude --- ..._happybell80_quote_rotation_improvement.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 troubleshooting/250926_happybell80_quote_rotation_improvement.md 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