Skip to content

[DP-387] GET /trends/analysis 트렌드 분석 API + Redis 캐시#132

Merged
suheon98 merged 1 commit intodevelopV2from
feature/DP-387-trends-analysis-api
Apr 24, 2026
Merged

[DP-387] GET /trends/analysis 트렌드 분석 API + Redis 캐시#132
suheon98 merged 1 commit intodevelopV2from
feature/DP-387-trends-analysis-api

Conversation

@suheon98
Copy link
Copy Markdown
Collaborator

Summary

  • GET /trends/analysis — 최신 트렌드 분석 결과 조회 (Redis 6h 캐시)
  • GET /trends/analysis/{periodStart} — 특정 기간 트렌드 분석 결과 조회 (Redis 24h 캐시)
  • AI 서버가 trend_snapshots.payload(JSONB)에 저장한 분석 결과를 파싱 후 camelCase로 반환
  • Redis 장애 시 PostgreSQL fallback, Redis 저장 실패는 무시하고 응답 정상 반환

Changes

파일 변경
TrendSnapshotRepository findFirstByUnitAndScopeOrderByPeriodStartDesc, findByUnitAndScopeAndPeriodStart
TopContentItem payload top_posts 항목 DTO (@JsonAlias snake_case 수용)
TrendAnalysisResponse 응답 DTO (@JsonAlias snake_case → camelCase)
TrendAnalysisService Redis 캐시 + PG fallback 서비스
TrendController 엔드포인트 2개 추가
ErrorCode TREND_NOT_FOUND 추가
SecurityConfig /trends/analysis/** authenticated 명시

Test plan

  • TrendAnalysisServiceTest — 8케이스 (캐시 hit/miss, PG 없음, Redis 장애 fallback, 저장 실패 무시)
  • TrendControllerTest — 4케이스 추가 (200 성공, 404, 특정 기간 200, 잘못된 날짜 400)
  • ./gradlew build --no-daemon 통과

Jira: https://devpick.atlassian.net/browse/DP-387

@sonarqubecloud
Copy link
Copy Markdown

@suheon98 suheon98 merged commit 19b9dec into developV2 Apr 24, 2026
4 checks passed
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.

1 participant