Skip to content

Feat/#126 타임라인 - 타임라인 수정, 조회 구현#134

Merged
kingmingyu merged 20 commits into
developfrom
feat/#126
May 18, 2026
Merged

Feat/#126 타임라인 - 타임라인 수정, 조회 구현#134
kingmingyu merged 20 commits into
developfrom
feat/#126

Conversation

@kingmingyu
Copy link
Copy Markdown
Collaborator

@kingmingyu kingmingyu commented May 16, 2026

📌 관련 이슈

🚀 개요

이번 PR에서 변경된 핵심 내용을 요약해주세요.
타임라인 수정 및 조회 구현

📄 작업 내용

구체적인 작업 내용을 설명해주세요.

  • 타임라인 상세 조회 시에 AI요약을 저장할 필드가 없어서 추가했습니다

  • 타임라인 조회

image 이름과 상태 날짜를 종료일 내림차순으로 반환
  • 타임라인 상세 조회
image

dailyTrend에 일별 데이터를 platformContributions에 플랫폼별 기여정보를 반환

  • 타임라인 수정

📸 스크린샷 / 테스트 결과 (선택)

결과물 확인을 위한 사진이나 테스트 로그를 첨부해주세요.

  • 전체 API
image image
  • 타임라인 목록 조회 API
image image
  • 타임라인 상세 조회 API
image image image
  • 타임라인 수정 API
image
  • 수정 후 상세 조회
image image

✅ 체크리스트

  • 브랜치 전략(GitHub Flow)을 준수했나요?
  • 메서드 단위로 코드가 잘 쪼개져 있나요?
  • 테스트 통과 확인
  • 서버 실행 확인
  • API 동작 확인

🔍 리뷰 포인트 (Review Points)

리뷰어가 중점적으로 확인했으면 하는 부분을 적어주세요. (P1~P4 적용 가이드)

  • MetricFact 쿼리문이 이전 pr에 있던 지민님 쿼리문이랑 비슷한 것 같아서 지민님 머지하시면 통합해보겠습니다
  • 캠페인별 기여도 정보는 각 지표(Click과 Conversion 2개라면 (Click의 각 플랫폼별 기여도) + (Conversion의 각 플랫폼별 기여도)의 평균으로 기여도를 계산했습니다.
  • 타임라인 생성은 모든 유저가 가능한데 삭제랑 수정은 ADMIN만 가능하게 해놨습니다.. 혹시 ADMIN이나 MEMBER로 통일하는 편이 괜찮을까요?

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

  • New Features

    • 타임라인 목록 조회 추가
    • 타임라인 상세 조회 추가 — 일별 지표 추이 및 플랫폼 기여도 포함
    • 타임라인 수정 API 추가
    • 타임라인 요약 정보(요약문) 저장 및 초기화 지원
  • Refactor

    • 접근 제어 오류 메시지 세분화(읽기/수정/삭제 권한별 구분)

Review Change Stack

@kingmingyu kingmingyu linked an issue May 16, 2026 that may be closed by this pull request
3 tasks
@kingmingyu kingmingyu requested review from jinnieusLab and ojy0903 May 16, 2026 06:08
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 10ee15de-d7d4-4657-8792-89b3d71ed174

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae7ca5 and 335e2c4.

📒 Files selected for processing (2)
  • src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineServiceImpl.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineServiceImpl.java

Walkthrough

타임라인 요약/상세 조회와 수정 API를 추가하고, MetricFact를 조회해 일별 지표 추이와 플랫폼 기여도를 계산하는 로직(집계·ROAS 계산·기여율 산정)을 구현했습니다. 권한 예외 코드를 세분화하고 관련 DTO/변환/컨트롤러/저장소를 확장했습니다.

Changes

Timeline 조회 및 수정 기능

Layer / File(s) Summary
응답 스키마 및 데이터 접근 계층
src/main/java/com/whereyouad/WhereYouAd/domains/timeline/application/dto/response/TimelineResponse.java, src/main/java/com/whereyouad/WhereYouAd/domains/timeline/persistence/entity/Timeline.java, src/main/java/com/whereyouad/WhereYouAd/domains/timeline/persistence/repository/TimelineRepository.java, src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.java
TimelineResponse에 요약/상세/일별/플랫폼 응답 DTO를 추가하고, Timeline 엔티티에 summaryupdate(...)/updateSummary(...)를 추가했습니다. TimelineRepositoryfindByOrganizationIdOrderByEndDateDesc를, MetricFactRepository에 조직·기간·grain 기반 조회 findByOrgAndPeriodAndGrain를 추가했습니다.
변환기·프레젠테이션 계층
src/main/java/com/whereyouad/WhereYouAd/domains/timeline/application/mapper/TimelineConverter.java, src/main/java/com/whereyouad/WhereYouAd/domains/timeline/presentation/TimelineController.java, src/main/java/com/whereyouad/WhereYouAd/domains/timeline/presentation/docs/TimelineControllerDocs.java
TimelineConvertertoTimelineSummaryList, toTimelineSummaryDTO, toTimelineDetailDTO를 추가했습니다. TimelineController에 GET 목록/GET 상세/PUT 수정 엔드포인트를 추가하고, TimelineControllerDocs의 Swagger 시그니처를 확장했습니다.
서비스 계약·예외 정비
src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineService.java, src/main/java/com/whereyouad/WhereYouAd/domains/timeline/exception/code/TimelineErrorCode.java
TimelineServiceupdateTimeline, getTimelines, getTimelineDetail 시그니처를 추가하고, TimelineErrorCode의 403 계열을 TIMELINE_DELETE_FORBIDDEN, TIMELINE_READ_FORBIDDEN, TIMELINE_UPDATE_FORBIDDEN으로 세분화했습니다.
서비스 구현: 수정·조회·집계 로직
src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineServiceImpl.java
updateTimeline(권한/범위/비교기간 검증 → 엔티티 업데이트 → 성과상태 재계산) 및 getTimelines/getTimelineDetail을 추가했습니다. 상세 조회는 Grain.DAILY MetricFact를 조회해 buildDailyTrend(일별 합산·ROAS 계산) 및 buildPlatformContributions(provider별 합계 → 활성 지표 대비 비율 평균으로 기여율 산정)을 수행합니다.

Sequence Diagram(s)

sequenceDiagram
    participant User as 사용자
    participant Controller as TimelineController
    participant Service as TimelineServiceImpl
    participant Repo as MetricFactRepository
    participant Conv as TimelineConverter

    User->>Controller: GET /api/org/{orgId}/timeline/{timelineId}
    Controller->>Service: getTimelineDetail(userId, orgId, timelineId)
    Service->>Service: 조직/멤버/타임라인 검증
    Service->>Service: buildMetricList() (활성 지표 구성)
    Service->>Repo: findByOrgAndPeriodAndGrain(orgId, startDate, endDate, Grain.DAILY)
    Repo-->>Service: List<MetricFact>
    Service->>Service: buildDailyTrend(metricFacts) -> 일별 합계, ROAS 계산
    Service->>Service: buildPlatformContributions(metricFacts) -> provider별 기여율 계산
    Service->>Conv: toTimelineDetailDTO(timeline, metrics, dailyTrend, platformContributions)
    Conv-->>Service: TimelineDetailDTO
    Service-->>Controller: TimelineDetailDTO
    Controller-->>User: DataResponse<TimelineDetailDTO> (200)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • jinnieusLab
  • ojy0903
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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
Title check ✅ Passed PR 제목이 주요 변경사항인 타임라인 수정 및 조회 구현을 명확하게 반영하고 있습니다.
Description check ✅ Passed PR 설명에 개요, 작업 내용, 스크린샷, 테스트 결과가 포함되어 있으며 템플릿의 주요 섹션을 충족하고 있습니다.
Linked Issues check ✅ Passed PR이 #126의 모든 주요 요구사항을 충족합니다: 타임라인 요약 조회, 상세 조회(일별 지표 및 플랫폼 기여도 포함), 타임라인 수정 기능이 구현되어 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 타임라인의 조회 및 수정 기능 구현과 관련되어 있으며, 불필요한 범위 외 변경이 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#126

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 and usage tips.

@kingmingyu kingmingyu self-assigned this May 16, 2026
@kingmingyu kingmingyu added ✨ Feature 새로운 기능 추가 🗄️ DB 데이터베이스, 엔티티, 마이그레이션 관련 labels May 16, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineServiceImpl.java`:
- Around line 240-279: buildDailyTrend currently only emits dates present in the
facts map, which omits empty dates between the timeline range; modify
buildDailyTrend to iterate from timeline.getStartDate() to
timeline.getEndDate(), use the existing byDate Map<LocalDate,List<MetricFact>>
to lookup dayFacts (empty list when missing), and produce a
TimelineResponse.DailyMetricDTO for every date in that range; when a date has no
facts treat numeric sums as 0 (or null if the metric is disabled via
timeline.isUseClick()/isUseConversion()/isUseImpression()), and compute ROAS the
same way as now but return null if totalSpend is zero. Ensure the method still
sorts by date and returns a continuous list for the full period.
- Around line 136-147: After updating the Timeline entity in TimelineServiceImpl
(after timeline.update(...) and before returning the response), clear or refresh
the AI summary so stale text isn't returned; either call a domain method like
timeline.clearAiSummary() or timeline.setAiSummary(null) to reset it, or invoke
the AI summary generator (e.g.,
aiSummaryService.generateAndSaveSummary(timeline) or similar) to immediately
regenerate and persist a new summary, then proceed to calculate
PerformanceStatus and return TimelineConverter.toCreateResponse(timeline).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f37e7a1f-a6c6-4ca5-ab00-bbce43d2189c

📥 Commits

Reviewing files that changed from the base of the PR and between d4d0130 and 7ae7ca5.

📒 Files selected for processing (10)
  • src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/application/dto/response/TimelineResponse.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/application/mapper/TimelineConverter.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineService.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/domain/service/TimelineServiceImpl.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/exception/code/TimelineErrorCode.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/persistence/entity/Timeline.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/persistence/repository/TimelineRepository.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/presentation/TimelineController.java
  • src/main/java/com/whereyouad/WhereYouAd/domains/timeline/presentation/docs/TimelineControllerDocs.java

@jinnieusLab
Copy link
Copy Markdown
Collaborator

P3: 넵 쿼리문 통합 되면 이어서 리뷰하도록 하겠습니다! 저는 타임라인 삭제랑 수정도 ADMIN이나 MEMBER 모두 가능하게 하는 게 좋을 것 같습니다!

Copy link
Copy Markdown
Collaborator

@ojy0903 ojy0903 left a comment

Choose a reason for hiding this comment

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

P4: 고생하셨습니다! 타임라인 상세 조회에서 날짜별로 지표 값 나타내는 로직이 복잡했을 거 같은데 잘 구현해주신거 같아요!! 저도 MetricFact 쿼리문 수정되면 한번 더 확인해보겠습니다. 그리고 제 생각에도 타임라인 수정, 삭제가 ADMIN, MEMBER 모두 가능하게 해도 좋을 것 같습니다!

# Conflicts:
#	src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.java
@kingmingyu
Copy link
Copy Markdown
Collaborator Author

provider와 grain을 둘 다 nullable로 만들면 JPQL에서 (:provider IS NULL OR m.provider = :provider) 같은 조건이 생기는데 이게 인덱스를 못탄다고 합니다..! 그래서 두 메서드 다 냅두는 것이 괜찮을 것 같아서 둘 다 뒀습니다!

@kingmingyu kingmingyu requested a review from ojy0903 May 17, 2026 05:18
@kingmingyu
Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Collaborator

@ojy0903 ojy0903 left a comment

Choose a reason for hiding this comment

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

P4: MetricFact 관련 repository 메서드 두개 모두 남긴 것 확인했습니다! JPQL 관련 이슈는 잘 몰랐었네요... 둘다 있어도 문제가 있는건 아닌 것 같아 괜찮아 보입니다!

Copy link
Copy Markdown
Collaborator

@jinnieusLab jinnieusLab left a comment

Choose a reason for hiding this comment

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

P4: 넵 수고하셨습니다! 머지해주시면 판별 로직 쪽도 금방 구현해보겠습니다..!

@kingmingyu kingmingyu merged commit fdad8c6 into develop May 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗄️ DB 데이터베이스, 엔티티, 마이그레이션 관련 ✨ Feature 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 타임라인 - 타임라인 조회, 수정 구현

3 participants