Skip to content

Dev#306

Merged
hyuuuun merged 2 commits into
mainfrom
dev
Mar 19, 2026
Merged

Dev#306
hyuuuun merged 2 commits into
mainfrom
dev

Conversation

@hyeonRS
Copy link
Copy Markdown
Contributor

@hyeonRS hyeonRS commented Mar 19, 2026

개요

관련 BackLog

Resolves: (Backlog Number, ...)

PR 유형

  • 새로운 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

PR Checklist

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Summary by CodeRabbit

  • Bug Fixes

    • Improved the accuracy of monthly data usage calculations by properly adjusting current month usage figures to combine personal usage amounts with normalized shared pool contributions.
  • Tests

    • Updated monthly usage tests to dynamically compute date values instead of relying on hard-coded constants, ensuring greater reliability and accuracy across different time periods.

@hyeonRS hyeonRS requested a review from hyuuuun March 19, 2026 19:30
@hyeonRS hyeonRS self-assigned this Mar 19, 2026
@hyuuuun hyuuuun merged commit cd13f84 into main Mar 19, 2026
2 of 3 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23116c43-2018-4ba4-b55a-ea94da8b1183

📥 Commits

Reviewing files that changed from the base of the PR and between 6c4d44b and bb554c8.

📒 Files selected for processing (2)
  • src/main/java/com/pooli/data/service/impl/DataServiceImpl.java
  • src/test/java/com/pooli/data/service/impl/DataServiceImplTest.java

📝 Walkthrough

Walkthrough

The getMonthlyDataUsage method now adjusts usage data for the current month by fetching real-time usage information via getDataUsage and normalizing shared pool amounts. Helper methods parse year-months, check current month eligibility, and perform the adjustment logic. The test is updated to use dynamic month computation instead of hard-coded values and mocks the timezone policy.

Changes

Cohort / File(s) Summary
Monthly Usage Adjustment Logic
src/main/java/com/pooli/data/service/impl/DataServiceImpl.java
Added adjustMonthlyUsage, isCurrentMonth, parseMonthlyUsageYearMonth, and toYearMonthValue helper methods. Modified getMonthlyDataUsage to compute adjustedUsages for current-month entries by fetching live data and normalizing shared pool amounts. Average calculation now uses adjusted usages instead of original usages.
Monthly Usage Test Adaptation
src/test/java/com/pooli/data/service/impl/DataServiceImplTest.java
Updated getMonthlyDataUsage_success_returnsAverage to use dynamic month computation via previousYearMonth() instead of hard-coded month values. Added mock expectation for trafficRedisRuntimePolicy.zoneId() returning Asia/Seoul. Mockito stubs now use computed months formatted as "yyyy-MM".

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DataService
    participant MonthParser
    participant ZonePolicy
    participant DataUsageService
    participant ResponseBuilder

    Caller->>DataService: getMonthlyDataUsage(lineId, yearMonth)
    DataService->>DataService: Fetch monthly usages from repository
    
    loop For each MonthlyUsageDto
        DataService->>MonthParser: parseMonthlyUsageYearMonth(usage)
        MonthParser-->>DataService: parsedYearMonth
        
        DataService->>ZonePolicy: Get configured zoneId()
        ZonePolicy-->>DataService: timeZone
        
        DataService->>DataService: isCurrentMonth(parsedYearMonth, zoneId)
        
        alt Current Month
            DataService->>DataUsageService: getDataUsage(lineId)
            DataUsageService-->>DataService: currentUsageData
            
            DataService->>DataService: adjustMonthlyUsage(lineId, usage)<br/>(sum personal + shared amounts)
            DataService-->>DataService: adjustedUsage
        else Previous Months
            DataService-->>DataService: use original usage unchanged
        end
    end
    
    DataService->>ResponseBuilder: Build response with adjustedUsages
    ResponseBuilder-->>DataService: MonthlyDataUsageResDto
    DataService-->>Caller: Return adjusted monthly data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Dev #303: Modifies getDataUsage internal computation of personal/shared amounts, which directly impacts the adjustment calculations in this PR.
  • Dev #258: Related to Redis-driven in-month adjustments and helper method additions in DataServiceImpl.

Suggested labels

bug

Suggested reviewers

  • pjh813
  • Iwantcod
  • Misu0616

Poem

🐰 A rabbit hops through months so fine,
Adjusting usage, line by line,
When current month comes into view,
Fresh data flows—the numbers true!
No stale predictions block the way,
Just accurate counts for today.

✨ 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 dev
📝 Coding Plan
  • Generate coding plan for human review comments

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.

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