Skip to content

Feat/analytics and post observer server#20

Open
kwang-i-coder wants to merge 3 commits into
developfrom
feat/analytics-and-post-observer-server
Open

Feat/analytics and post observer server#20
kwang-i-coder wants to merge 3 commits into
developfrom
feat/analytics-and-post-observer-server

Conversation

@kwang-i-coder

Copy link
Copy Markdown
Contributor

개요

analytics API 엔드포인트 추가 및 post_observer 서버화

변경 사항

feat(analytics): analytics API 엔드포인트 추가

  • 개인 통계 요약 (총 게시글, 활동일수, 레벨, 랭킹 등)
  • 개인 카테고리 비율
  • 개인 키워드 랭킹
  • 전체 유저 카테고리 비율
  • 전체 유저 키워드 랭킹
  • 랭킹 분모를 전체 유저 수 → 해당 기간 내 활동 유저 수로 수정

feat(post-observer): post_observer HTTP 서버화

  • CronJob 방식에서 FastAPI 서버로 전환
  • 플랫폼 등록 시 기존 글 수집
  • 새 글 수집 및 RabbitMQ 발행
  • 비활성 유저 메일 알림 발행
  • URL 본문 크롤링
  • 티스토리 수집 전략을 RSS → sitemap.xml 전체 수집으로 변경
  • 서버 간 호출에 X-Internal-Token 헤더 인증 추가
  • 플랫폼 등록 시 RabbitMQ 대신 post_observer HTTP 호출로 변경
  • check_inactive_users에서 RabbitMQ 발행 성공 후 DB 업데이트하도록 순서 수정

- /analytics/summary, /category-ratios, /keyword-rankings 추가
- /analytics/global/category-ratios, /global/keyword-rankings 추가
- AnalyticsRepository, AnalyticsService, AnalyticsRouter 구현
- main.py에 analytics 전용 예외 핸들러 추가
- get_user_ranking 분모를 기간 내 활동 유저 수 기준으로 수정
- FastAPI 서버(server.py) 및 observer 라우터 추가
- RSS 파싱, 본문 크롤링, 플랫폼 등록, 새글 확인 엔드포인트 추가
- 티스토리 sitemap 기반 전체 글 수집 파서 추가
- 내부 인증 토큰(X-Internal-Token) 검증 미들웨어 추가
- check_inactive_users에서 RabbitMQ 발행 후 DB 업데이트하도록 수정
- 플랫폼 등록 시 post_observer에 HTTP로 수집 요청하도록 변경
- Dockerfile 및 docker-compose uvicorn 서버 실행으로 업데이트
@kwang-i-coder kwang-i-coder requested a review from jdk829355 March 28, 2026 14:44
Comment thread main_server/app/main.py
app.include_router(router=trend_router)
app.include_router(router=analytics_router)

def _is_analytics_path(request: Request) -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요 함수의 역할은 뭔가요

]


def register_platform(user_id: str, platform_name: str, account_id: str) -> int:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 메인서버에서 platform_register 큐에 메시지를 발행하는 것 대신에 여기에 요청을 날리고, 여기서 글 url 목록을 뽑은 후에 new_posts 큐로 메시지를 발행하는 건가요?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞으면 아키텍처쪽에 반영 부탁드림다

for post in posts:
published_at = post.get("published_at")
messages.append(
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아키텍처에 요 스키마도 같이 추가해주세요 그래야 다른 부분 개발하기 편합니다..

)

return
return UserPlatformResponse(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

명세서 맞춰주세요

)
platform_service.delete_user_platform_mapping(db, user_id, platform_info.platform_id, req.platform_name)

return {"message": "삭제 완료"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 부탁드림다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platform쪽은 @yoonaji 께서 리팩터링을 진행하고있는데, 이걸 같이 건들면 좋진 않을 것 같습니다. 옵저버의 클라이언트를 사용하는 코드를 추가한다고 해도 @yoonaji 가 추가하는 게 혼동을 줄일 수 있을 것 같습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mail_reminders, new_posts에 대한 스키마를 아키텍처에 적어주시길 부탁드립니다.
메일은 일단 어디서 소비할 지 봐야겠는데 new_posts는 ai서버에서 키워드랑 카테고리 추출하고 db에 insert하면 될 것 같네요

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants