Skip to content

[article] 조회수 집계 및 인기 문서 API 추가 - #41

Merged
ZaMan0806 merged 4 commits into
feat/article-category-apifrom
feat/article-view-count
Oct 13, 2026
Merged

ZaMan0806 merged 4 commits into
feat/article-category-apifrom
feat/article-view-count

Conversation

@ZaMan0806

@ZaMan0806 ZaMan0806 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • 조회수를 집계하고 인기 문서 목록 API를 추가합니다.

Closes #26

Changes

  • 문서 조회(GET /articles/{id}, /by-title) 시 조회수 증가, 응답 viewCount에 누적 값 포함. 공동편집 부트스트랩 등 내부 조회는 세지 않음
  • 중복 집계 정책: 같은 조회자(로그인=계정 id, 비로그인=IP+User-Agent 해시)의 30분 내 재조회는 집계하지 않음(article.views.dedupe-minutes). 비로그인 조회마다 세션을 만들지 않음
  • Redis(누적·미반영 증가분)에 쌓고 30초 주기로 articles.view_count에 반영. 읽기 경로가 MySQL을 보지 않도록 누적값도 Redis에 둠
  • 반영은 벌크 UPDATE라 updatedAt(최근 변경 목록)에 영향이 없고, 엔티티는 view_count를 쓰지 않아(updatable=false) 문서 수정이 오래된 값으로 덮어쓰지 않음
  • GET /api/v1/articles/popular?size= — 전체 기간 조회수 순
  • Redis 장애가 문서 조회를 막지 않도록 집계 실패 시 기존 응답 유지

Test

  • ./mill test, ./mill spotless --check 통과
  • 카운터(첫 조회/중복/시드), 반영 스케줄러(성공/실패 유지), 조회자 키, 벌크 증가·덮어쓰기 방지·인기순 @DataJpaTest

주의

리버스 프록시 뒤에서는 server.forward-headers-strategy로 실제 클라이언트 주소가 전달돼야 비로그인 조회자가 구분됩니다. 반영 직후·삭제 전에 프로세스가 죽으면 한 주기 분량이 한 번 더 반영될 수 있습니다(유실보다 낫다고 판단).

Checklist

  • I checked that this PR matches the project conventions.
  • I ran the relevant tests or explained why they were not run.
  • I updated documentation or configuration when needed.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@ZaMan0806
ZaMan0806 added this pull request to stack #43 October 12, 2026 02:15
@ZaMan0806
ZaMan0806 force-pushed the feat/article-view-count branch from 8013995 to e5f604e Compare October 12, 2026 02:18
@ZaMan0806
ZaMan0806 force-pushed the feat/article-view-count branch from e5f604e to b0ce51f Compare October 12, 2026 02:23
@ZaMan0806
ZaMan0806 force-pushed the feat/article-view-count branch 2 times, most recently from 281c631 to e00fe3b Compare October 12, 2026 03:10
@ZaMan0806
ZaMan0806 force-pushed the feat/article-view-count branch from e00fe3b to 8dcdc92 Compare October 12, 2026 03:13
- 문서 조회(GET, 제목 조회 포함) 시 조회수 증가, 같은 조회자의 30분 내 재조회는 집계하지 않음
- 조회수는 Redis에 쌓았다가 주기적으로 articles.view_count에 반영 (벌크 UPDATE라 최근 변경·수정 시각에 영향 없음)
- 문서 조회 응답에 viewCount 포함, GET /api/v1/articles/popular 추가
- Redis 집계 장애가 문서 조회를 막지 않도록 실패 시 기존 응답 유지

Closes #26
- 플러시가 pending을 processing으로 옮긴 뒤 MySQL에 반영하기 전에 누적값을 다시 채우면 그 증가분이 빠져 낮게 시드되던 문제 수정
@ZaMan0806
ZaMan0806 force-pushed the feat/article-view-count branch from 8dcdc92 to e68d61d Compare October 12, 2026 03:26
@ZaMan0806 ZaMan0806 changed the title feat(article): 조회수 집계 및 인기 문서 API 추가 [article] 조회수 집계 및 인기 문서 API 추가 Oct 12, 2026
snowykte0426
snowykte0426 previously approved these changes Oct 13, 2026
@ZaMan0806
ZaMan0806 merged commit e3bbf6f into develop Oct 13, 2026
2 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.

2 participants