From d372c9c9ba22632c92c118f07947c2896b9ce0fe Mon Sep 17 00:00:00 2001 From: happybell80 Date: Mon, 8 Sep 2025 01:05:17 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Company-X=20=EB=89=B4=EC=8A=A4=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=86=B5=ED=95=A9=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0=20=EB=AC=B8=EC=84=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문제: skill-news가 본문/요약 없이 URL/제목만 저장 - 해결: companyx_news_posting.json으로 전체 데이터 통합 - 시간 파싱 기능 추가 및 단계별 업데이트 구현 - company-x_hompage와 동일한 JSON 구조 적용 --- ...08_skill_news_companyx_data_integration.md | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 troubleshooting/250908_skill_news_companyx_data_integration.md diff --git a/troubleshooting/250908_skill_news_companyx_data_integration.md b/troubleshooting/250908_skill_news_companyx_data_integration.md new file mode 100644 index 0000000..a4fe181 --- /dev/null +++ b/troubleshooting/250908_skill_news_companyx_data_integration.md @@ -0,0 +1,97 @@ +# Company-X 뉴스 데이터 통합 문제 해결 + +## 배경 +- **날짜**: 2025-09-08 +- **문제**: skill-news가 Company-X 뉴스를 수집하지만 본문과 요약이 없어 skill-publish가 홈페이지에 게시할 수 없음 +- **원인**: companyx_news_collector.py가 제목/URL만 저장하고 스크래핑/요약 결과를 버림 + +## 문제 상황 + +### 1. 초기 증상 +- rb8001이 skill-news에서 Company-X 뉴스 15개 찾았지만 0개 전달받음 +- skill-publish가 받은 데이터에 summary, content, thumbnail_url 없음 +- Squarespace 홈페이지 게시 불가 + +### 2. 근본 원인 +```python +# 기존 companyx_history.json 구조 (문제) +{ + "articles": [ + { + "url": "https://...", + "title": "제목", + "timestamp": "2025-09-07T15:38:56" + } + ] +} +``` +- 단순 중복 체크용으로만 사용 +- 스크래핑/요약 데이터 저장 안 함 +- 매번 동일 기사 재처리 + +### 3. company-x_hompage와의 차이 +- company-x_hompage: 3단계 JSON 파일로 전체 데이터 저장 +- skill-news: URL/제목만 저장하고 나머지 버림 + +## 해결 과정 + +### 1. 시간 파싱 기능 추가 +```python +def _parse_time_text(self, time_text: str) -> str: + """Google News 시간 텍스트를 날짜 문자열로 변환 (YYYY-MM-DD)""" + # "3일 전", "5시간 전" → "2025-09-05" 형식으로 변환 +``` + +### 2. NewsArticle 모델 확장 +```python +time_text: Optional[str] = Field(None, description="원본 시간 텍스트") +found_at: Optional[datetime] = Field(None, description="실제 수집 시각") +``` + +### 3. companyx_news_posting.json으로 통합 +```python +# 새로운 구조 (company-x_hompage 형식) +{ + "keyword": "컴퍼니엑스", + "last_updated": "2025-09-08T...", + "total_count": 5, + "articles": { + "article_id": { + "id": "article_id", + "title": "제목", + "publisher": "언론사", + "parsed_date": "2025-09-05", + "time_text": "3일 전", + "found_at": "2025-09-08T...", + "url": "https://...", + "content": "본문 전체", + "actual_url": "리다이렉트 후 URL", + "thumbnail_url": "썸네일 URL", + "scraped_at": "2025-09-08T...", + "summary": "280-320자 요약", + "summary_length": 285, + "company_name": "COMPANY X", + "summarized_at": "2025-09-08T...", + "status": "summarized" + } + } +} +``` + +### 4. 업데이트 메서드 구현 +- `update_scraped_data()`: 스크래핑 후 데이터 업데이트 +- `update_summarized_data()`: 요약 후 데이터 업데이트 +- 각 단계별로 기존 데이터에 추가 정보 누적 + +## 최종 결과 +- 하나의 `companyx_news_posting.json` 파일에 모든 데이터 통합 +- 수집 → 스크래핑 → 요약 단계별 업데이트 +- 캐시 효과로 재처리 방지 +- skill-publish가 필요한 모든 필드 제공 + +## 교훈 +1. **데이터 손실 방지**: 비싼 연산(스크래핑/AI 요약) 결과는 반드시 저장 +2. **참조 구현 확인**: company-x_hompage 같은 검증된 구현 참고 +3. **통합 테스트**: rb8001 → skill-news → skill-publish 전체 파이프라인 테스트 +4. **환경변수 활용**: 하드코딩 대신 환경변수로 설정 관리 +5. **단계별 상태 추적**: collected → scraped → summarized 상태 관리 \ No newline at end of file