Refactor/#167 대시보드 성과 집계 방식 개선 - 조직 기반 데이터 집계로 수정#170
Conversation
This reverts commit 91224c8.
… project 를 사용해 organization 과 연관성을 찾도록 수정
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough대시보드 성과 집계 기준을 전체 데이터 최신 timeBucket에서 조직(orgId) 기준 최신 timeBucket으로 변경했습니다. MetricFactRepository에 findLatestTimeBucketByOrgId가 추가되어 기존 메서드를 대체했고, DashboardServiceImpl은 이를 활용해 currentEnd(+1일) 기준으로 집계 기간을 재계산합니다. Changes조직 기반 대시보드 집계
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant DashboardServiceImpl
participant MetricFactRepository
participant Database
DashboardServiceImpl->>MetricFactRepository: findLatestTimeBucketByOrgId(orgId)
MetricFactRepository->>Database: MetricFact JOIN project WHERE organization.id = orgId
Database-->>MetricFactRepository: 최신 timeBucket
MetricFactRepository-->>DashboardServiceImpl: latestDate
DashboardServiceImpl->>DashboardServiceImpl: currentEnd = latestDate.plusDays(1)
DashboardServiceImpl->>DashboardServiceImpl: oneMonthAgo/twoMonthsAgo 재계산
DashboardServiceImpl->>MetricFactRepository: findMetricsSumByOrgIdAndDateRange(..., currentEnd)
DashboardServiceImpl->>MetricFactRepository: findMetricsSumByOrgIdAndProvider(..., currentEnd)
Possibly related PRs
Suggested reviewers: 시니어 개발자 시점에서 한마디 남기자면요, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/advertisement/persistence/repository/MetricFactRepository.java`:
- Around line 32-37: Update findLatestTimeBucketByOrgId in MetricFactRepository
so the latest timeBucket is computed with the same active/ongoing filters used
by the aggregation queries, rather than taking MAX over all MetricFact rows for
the organization. Add the necessary conditions tied to the project/org status
(OrgStatus.ACTIVE and Status.ON_GOING) in the JPQL, and adjust the nearby
comment to say “해당 조직” instead of “해당 프로젝트” to match the method’s scope.
🪄 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: 23f1391d-7eba-416c-889e-de46c41af4ba
📒 Files selected for processing (2)
src/main/java/com/whereyouad/WhereYouAd/domains/advertisement/persistence/repository/MetricFactRepository.javasrc/main/java/com/whereyouad/WhereYouAd/domains/dashboard/domain/service/DashboardServiceImpl.java
kingmingyu
left a comment
There was a problem hiding this comment.
P4: 고생하셨습니다! 이런 문제가 있었군요.. 프로젝트 관련해서는 저희가 기존 광고 계정을 연동하고 광고 데이터를 불러오면 그걸 목적에 맞는 프로젝트를 생성해서 그 프로젝트끼리 데이터를 비교하고 분석하는 걸로 기억을 해서 지금도 상태도 괜찮을 것 같습니다!
jinnieusLab
left a comment
There was a problem hiding this comment.
P4: 오 고생하셨습니다! 지표가 전체에 대해서 조회 되도록 구현된 줄은 몰랐는데 발견해주셔서 다행이네요... 감사합니다!
제 생각에도 유저가 프로젝트 생성 시 원하는 캠페인을 선택하여 묶고 있는 흐름이니, 지금처럼 Project 연관 관계에 해당하는 캠페인들만 지표에 반영하는 방향으로 그대로 가도 될 것 같습니다!
📌 관련 이슈
🚀 개요
대시보드 전체 지표 조회 (
GET /api/dashborad/{orgId}/metrics) API 에서 가장 최신 time_bucket 조회를 DB 테이블 전체 기준이 아닌 각 조직 기준으로 조회하도록 개선📄 작업 내용
📸 스크린샷 / 테스트 결과 (선택)
기존 develop 브랜치에 timebucket 최신값 로깅을 추가하고 테스트

DB 상태 : MetricFact 테이블에서 가장 최근 timeBucket 은 6월20일, 모든 metricFact 는 orgId=1 인 조직의 project 에 소속


develop 브랜치

API 정상 응답
서버 로그 내부 timeBucket 최신 값 6월 20일 확인

project_id=2 인 임의의 project 생성 후 (org_id = 2 에 소속), 해당 project 에 속하는 임의의 metricFact 값 추가


API 호출 결과 다른 조직의 최신 time_bucket 값이 로그로 조회됨.


---> 이와 같이 기존에는 해당 time_bucket 최신값이 조직 상관없이 테이블 내에서 가장 최신 값으로 조회되는 방식이였는데, 이 최신값이 각 조직 별 metricFact 의 최신값으로 조회되어야 할 것 같아 이를 개선했습니다.

refactor/#167 브랜치다른 조직의 데이터 값이 존재하여도 요청값에 있는 조직의 최신 time_bucket 으로 조회됨을 확인


✅ 체크리스트
🔍 리뷰 포인트 (Review Points)
-> 커밋 내역 중에 Revert 로 되돌린 커밋이 이 Project로 연동되지 않은 AdCampaign 도 지표 계산에 포함되도록 했다가 되돌린 작업입니다...
Summary by CodeRabbit