DOCS/troubleshooting/250926_happybell80_quote_rotation_improvement.md
happybell80 12ba27bac0 docs: 명언 로테이션 개선 문서 최종 업데이트
- 60개 메시지 확장 반영
- 날짜 기반 구현 코드 문서화

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 11:38:53 +09:00

1.8 KiB

명언 로테이션 개선

날짜: 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)

def _get_random_messages(self) -> Tuple[str, str, Tuple[str, str, str]]:
    """랜덤 오프닝/클로징/명언 메시지 선택"""
    # 라인 111: random.choice(openings)
    # 라인 113: random.choice(closings)
    # 라인 116: random.choice(quotes)

문제점

  • 완전 랜덤 선택으로 같은 명언이 연속 반복될 수 있음
  • 60개 오프닝, 60개 클로징, 60개 명언으로 확장됨 (파일 수정됨)
  • 로테이션 순서나 사용 기록 추적 없음
  • 환경변수(HEADLINES_OPENER/CLOSER) 설정 시 랜덤 선택 건너뜀 (라인 105-107)

2. 개선 방안

로테이션 방식 (날짜 기반)

  • 오늘 날짜를 기준으로 인덱스 계산
  • 인덱스 = (오늘의 일수) % (명언 개수)
  • DB 수정 불필요, 코드만 변경
  • 60개 메시지로 약 6번/년 반복 (기존 20개는 18번/년)

구현 필요사항

  1. _get_random_messages() 메서드 수정
  2. random.choice() 대신 날짜 기반 인덱스 사용
    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까지)