Skip to content

in-348-인플루언서-인사이트-조회-최적화 -> develop - #214

Merged
HanYoonSoo merged 3 commits into
developfrom
in-348-인플루언서-인사이트-조회-최적화
Jul 2, 2026

Hidden character warning

The head ref may contain hidden characters: "in-348-\uc778\ud50c\ub8e8\uc5b8\uc11c-\uc778\uc0ac\uc774\ud2b8-\uc870\ud68c-\ucd5c\uc801\ud654"
Merged

HanYoonSoo merged 3 commits into
developfrom
in-348-인플루언서-인사이트-조회-최적화

Conversation

@HanYoonSoo

@HanYoonSoo HanYoonSoo commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Issue


comment

  • 인플루언서 인사이트 조회 시 전체 영상 조회를 제거하고 최신 50개/최근 30일 포맷 분석 조회로 분리했습니다.
  • 최근 30일 롱폼/숏폼 분석은 Projection으로 필요한 통계만 조회하도록 변경했습니다.
  • 50개 미만 채널의 바이럴/광고 경험 비율은 실제 영상 수 기준으로 계산하도록 조정했습니다.

Summary by CodeRabbit

  • New Features

    • 최근 영상과 포맷 통계를 함께 반영해 인사이트 계산이 개선되었습니다.
    • 최신 영상 조회가 최대 50개로 제한되고, 최근 30일 기준의 포맷 분석이 추가되었습니다.
  • Bug Fixes

    • 조회율 계산의 기준이 실제 집계된 데이터 수에 맞게 조정되어, 데이터가 부족한 경우에도 더 정확한 비율이 표시됩니다.
    • 최근 설명 목록이 최신 영상 데이터와 일치하도록 개선되었습니다.
  • Tests

    • 인사이트 계산 및 최근 기간 기준 동작을 검증하는 테스트가 추가되었습니다.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@HanYoonSoo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f0affbf-9092-4084-a55f-7022ce4f2155

📥 Commits

Reviewing files that changed from the base of the PR and between 26568b8 and 66acd1f.

📒 Files selected for processing (1)
  • src/main/java/com/example/inflace/domain/video/repository/VideoRepository.java

Walkthrough

VideoFormatStatsProjection 레코드를 신규 추가하고, VideoRepository에 카운트·페이징·JPQL 프로젝션 메서드를 추가한다. InfluencerInsightCalculator.calculate()의 시그니처에 recentFormatProjections를 추가하고 buildFormatAnalysis를 프로젝션 기반으로 교체하며, calculateFixedWindowPercentOf 분모를 실제 입력 크기로 변경한다. InfluencerInsightQueryService는 count 검증 → 페이징 조회 → UTC 기준 30일 프로젝션 조회 순으로 흐름이 재구성된다.

Changes

포맷 분석 프로젝션 도입 및 인사이트 조회 개선

Layer / File(s) Summary
VideoFormatStatsProjection 레코드 및 Repository 메서드 추가
src/main/java/com/example/inflace/domain/video/repository/projection/VideoFormatStatsProjection.java, src/main/java/com/example/inflace/domain/video/repository/VideoRepository.java
isShort, viewCount, likeCount, commentCount를 담는 VideoFormatStatsProjection record를 신규 정의하고, VideoRepository에 countByChannelId, 페이징 오버로드, JPQL 기반 포맷 통계 조회 메서드를 추가한다.
InfluencerInsightCalculator 시그니처 및 buildFormatAnalysis 로직 교체
src/main/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculator.java
calculate() 파라미터에 recentFormatProjections를 추가하고, buildFormatAnalysis를 VideoMetric 기반에서 VideoFormatStatsProjection 기반으로 전환한다. calculateFixedWindowPercentOf 분모를 metrics.size()로 변경하고 averageFormatViewCount, averageFormatEngagementRate 헬퍼를 도입한다.
InfluencerInsightQueryService 조회 흐름 변경
src/main/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightQueryService.java
getInsightQueryResult에서 최소 영상 조건을 countByChannelId로 검증하고, 최근 영상을 PageRequest(50개)로 조회한다. UTC 기준 30일 cutoff로 recentFormatProjections를 별도 조회하여 계산기에 전달하고, 최근 설명 목록 소스를 latestVideos로 변경한다.
Calculator 및 QueryService 단위 테스트 추가
src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java, src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightQueryServiceTest.java
비디오 수 부족 시 viral rate 분모, 30일 projection 기반 포맷 분석을 검증하는 Calculator 테스트와, 페이징 크기(50), UTC cutoff 범위, 최근 설명 목록 일치를 ArgumentCaptor로 검증하는 QueryService 테스트를 추가한다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • JECT-Study/inflace-4th-server#114: InfluencerInsightCalculator의 calculateFixedWindowPercentOf 및 content-window 기반 비율 계산 로직을 함께 수정한 PR로, 이번 PR의 분모 변경과 직접 연관된다.
  • JECT-Study/inflace-4th-server#119: buildFormatAnalysis의 long/short 포맷 카운트 구성과 FormatMetric 응답 구조를 변경한 PR로, 이번 PR의 포맷 분석 경로 전환과 맞물린다.

Suggested labels

👨🏻‍💻backend

Suggested reviewers

  • MINUUUUUUUUUUUU
  • youcastle03

Poem

🐇 토끼가 코드를 깡충깡충 뛰어넘어
VideoFormatStats 레코드를 새로 심었네
30일 UTC 기준, 분모도 실제 크기로
페이징 50개, 프로젝션 착착 전달
포맷 분석이 이제 제대로 달린다냥! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 인플루언서 인사이트 조회 최적화라는 핵심 변경을 반영해 변경 내용과 대체로 잘 맞습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch in-348-인플루언서-인사이트-조회-최적화

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java (2)

20-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

adExperienceRate도 같이 고정해 주세요.

이번 변경 범위에는 viral뿐 아니라 ad experience 분모 수정도 포함되는데, 현재 테스트는 viral 지표만 확인해서 해당 경로 회귀를 놓칠 수 있습니다. latestVideos가 50개 미만일 때 adExperienceRate도 실제 입력 개수를 분모로 쓰는지 함께 단언하는 편이 안전합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java`
around lines 20 - 56, Update the InfluencerInsightCalculatorTest coverage to
include the adExperienceRate path as well as the viral rates. In
viralRatesUseActualMetricCountWhenLatestVideosAreLessThanFifty, after calling
calculate on InfluencerInsightCalculator, add an assertion for
response.content().adExperienceRate() to verify it uses the actual number of
latestVideos as the denominator when fewer than fifty videos are provided,
alongside the existing viral2xRate and viral5xRate checks.

58-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

포맷 분석 테스트에서 평균값도 함께 검증해 주세요.

지금은 count만 확인해서 projection 기반 전환 이후 평균 조회수나 평균 참여율 계산이 잘못돼도 테스트가 통과합니다. 이번 리팩터링의 핵심이 projection에서 통계를 직접 계산하는 점이라, long/short의 평균값까지 같이 고정해 두는 게 좋겠습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java`
around lines 58 - 87, The format analysis test in
InfluencerInsightCalculatorTest only asserts longForm/shortForm counts, so it
can miss regressions in projection-based aggregation. Update
formatAnalysisUsesRecentThirtyDayProjectionRows to also verify the average
metrics computed in InfluencerInsightCalculator.calculate, especially the
longForm and shortForm averages derived from VideoFormatStatsProjection, so the
test locks down both count and mean calculations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java`:
- Around line 20-56: Update the InfluencerInsightCalculatorTest coverage to
include the adExperienceRate path as well as the viral rates. In
viralRatesUseActualMetricCountWhenLatestVideosAreLessThanFifty, after calling
calculate on InfluencerInsightCalculator, add an assertion for
response.content().adExperienceRate() to verify it uses the actual number of
latestVideos as the denominator when fewer than fifty videos are provided,
alongside the existing viral2xRate and viral5xRate checks.
- Around line 58-87: The format analysis test in InfluencerInsightCalculatorTest
only asserts longForm/shortForm counts, so it can miss regressions in
projection-based aggregation. Update
formatAnalysisUsesRecentThirtyDayProjectionRows to also verify the average
metrics computed in InfluencerInsightCalculator.calculate, especially the
longForm and shortForm averages derived from VideoFormatStatsProjection, so the
test locks down both count and mean calculations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0f2e379-ce6b-4212-8e60-b81ac9ac4dac

📥 Commits

Reviewing files that changed from the base of the PR and between d6f5d9f and 26568b8.

📒 Files selected for processing (6)
  • src/main/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculator.java
  • src/main/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightQueryService.java
  • src/main/java/com/example/inflace/domain/video/repository/VideoRepository.java
  • src/main/java/com/example/inflace/domain/video/repository/projection/VideoFormatStatsProjection.java
  • src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightCalculatorTest.java
  • src/test/java/com/example/inflace/domain/channel/service/insight/InfluencerInsightQueryServiceTest.java

@youcastle03 youcastle03 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

고생하셨습니다!!

@HanYoonSoo
HanYoonSoo merged commit 152dfae into develop Jul 2, 2026
3 checks passed
@HanYoonSoo
HanYoonSoo deleted the in-348-인플루언서-인사이트-조회-최적화 branch July 2, 2026 04:58
@HanYoonSoo HanYoonSoo self-assigned this Jul 2, 2026
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