Skip to content

Dev#258

Merged
pjh813 merged 12 commits into
mainfrom
dev
Mar 17, 2026
Merged

Dev#258
pjh813 merged 12 commits into
mainfrom
dev

Conversation

@hyeonRS
Copy link
Copy Markdown
Contributor

@hyeonRS hyeonRS commented Mar 17, 2026

개요

  • 데이터 잔여량 및 사용량 관련 조회 API 내부에 Redis 실시간 데이터 현황 반영 로직 추가
  • Sentinel 관련 프로필 및 CD 실패 관련 수정

관련 BackLog

Resolves: (Backlog Number, ...)

PR 유형

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

PR Checklist

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced data usage calculations with real-time balance tracking for more accurate consumption metrics.
    • Added visibility of shared pool remaining data in family member details.
    • Introduced shared data limit status tracking for family pools.
  • Infrastructure

    • Configured Redis Sentinel for improved system reliability and high availability.

@hyeonRS hyeonRS requested review from Iwantcod, Misu0616 and pjh813 March 17, 2026 01:12
@hyeonRS hyeonRS added bug 버그 관련 feature 새 기능 개발 priority:high 우선순위: 상 labels Mar 17, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e72115b6-3748-4a4b-b78f-97a27787d343

📥 Commits

Reviewing files that changed from the base of the PR and between 195ed24 and 96dde0b.

📒 Files selected for processing (12)
  • src/main/java/com/pooli/data/mapper/DataMapper.java
  • src/main/java/com/pooli/data/service/impl/DataServiceImpl.java
  • src/main/java/com/pooli/family/domain/dto/response/FamilyMembersResDto.java
  • src/main/java/com/pooli/family/service/FamilySharedPoolsService.java
  • src/main/java/com/pooli/family/service/impl/FamilyServiceImpl.java
  • src/main/java/com/pooli/traffic/service/runtime/TrafficRemainingBalanceQueryService.java
  • src/main/resources/application.yaml
  • src/main/resources/mapper/data/DataMapper.xml
  • src/main/resources/mapper/family/FamilyMapper.xml
  • src/test/java/com/pooli/data/service/impl/DataServiceImplTest.java
  • src/test/java/com/pooli/family/service/FamilySharedPoolsServiceTest.java
  • src/test/java/com/pooli/family/service/impl/FamilyServiceImplTest.java

📝 Walkthrough

Walkthrough

This pull request introduces Redis-backed traffic balance caching for data and family services. A new TrafficRemainingBalanceQueryService resolves actual remaining balances by combining database values with Redis-cached adjustments. Services now apply this balance resolution when querying family members and data usage, with updated DTOs and mappers to support additional cached balance fields.

Changes

Cohort / File(s) Summary
New Balance Resolution Service
src/main/java/com/pooli/traffic/service/runtime/TrafficRemainingBalanceQueryService.java
Adds new service with two public methods (resolveIndividualActualRemaining, resolveSharedActualRemaining) that combine DB remaining values with Redis-derived balances via safe arithmetic, null handling, and overflow protection.
Data Service Redis Integration
src/main/java/com/pooli/data/service/impl/DataServiceImpl.java
Introduces Redis-backed balance augmentation with in-month traffic recalculation logic; adds helper methods for reading buffered amounts from Redis, safe arithmetic, and daily/monthly usage queries from both DB and cache.
Data Mapper & Schema
src/main/java/com/pooli/data/mapper/DataMapper.java, src/main/resources/mapper/data/DataMapper.xml
Adds new public mapper method findDailyTotalUsageByLineIdAndDate returning daily total usage for a line on a specific date via MyBatis select query.
Family Service Balance Resolution
src/main/java/com/pooli/family/service/FamilySharedPoolsService.java
Injects TrafficRemainingBalanceQueryService and replaces direct balance usage with resolved actual balances across multiple methods; updates error handling, logging, and Korean localization for year-month parsing and event titles.
Family Service Member Enrichment
src/main/java/com/pooli/family/service/impl/FamilyServiceImpl.java
Introduces TrafficRemainingBalanceQueryService dependency and adds per-member balance enrichment via new helper methods (enrichFamilyMember, resolveSharedPoolRemainingAmount) during family member retrieval.
Family DTOs & Mappers
src/main/java/com/pooli/family/domain/dto/response/FamilyMembersResDto.java, src/main/resources/mapper/family/FamilyMapper.xml
Adds Lombok constructors (AllArgsConstructor, NoArgsConstructor with PRIVATE access) to outer class; adds new fields sharedPoolRemainingData (Long) and inner class field sharedLimitActive (Boolean) both marked @JsonIgnore and @Schema(hidden=true); mapper XML adds corresponding result column aliases.
Configuration & Persistence
src/main/resources/application.yaml
Adds Redis Sentinel configuration for cache and streams instances (master, nodes, password properties) for high-availability support.
Test Coverage
src/test/java/com/pooli/data/service/impl/DataServiceImplTest.java, src/test/java/com/pooli/family/service/FamilySharedPoolsServiceTest.java, src/test/java/com/pooli/family/service/impl/FamilyServiceImplTest.java
Expands test mocks to include TrafficRemainingBalanceQueryService and Redis components (StringRedisTemplate, HashOperations, ValueOperations); adds test scenarios for Redis-backed balance merging, zone-aware key generation, current-month calculations, and shared limit handling; updates test assertions to reflect merged balances.

Sequence Diagram

sequenceDiagram
    participant Client
    participant FamilyService
    participant TrafficRemainingBalanceQueryService
    participant DataMapper
    participant TrafficQuotaCacheService
    participant Redis
    participant Database

    Client->>FamilyService: getFamilyMembers()
    FamilyService->>DataMapper: Query family members + pool data
    DataMapper->>Database: SELECT family members with pool columns
    Database-->>DataMapper: Return DB pool data
    DataMapper-->>FamilyService: FamilyMembersResDto list
    
    FamilyService->>TrafficRemainingBalanceQueryService: resolveSharedActualRemaining(familyId, dbRemaining)
    TrafficRemainingBalanceQueryService->>TrafficQuotaCacheService: readAmountOrDefault(redisKey)
    TrafficQuotaCacheService->>Redis: GET cached balance
    Redis-->>TrafficQuotaCacheService: Return cached balance
    TrafficQuotaCacheService-->>TrafficRemainingBalanceQueryService: Redis balance value
    TrafficRemainingBalanceQueryService->>TrafficRemainingBalanceQueryService: safeAdd(dbRemaining, redisBalance)
    TrafficRemainingBalanceQueryService-->>FamilyService: Actual remaining balance
    
    FamilyService->>FamilyService: enrichFamilyMember(actualRemaining)
    FamilyService-->>Client: Return enriched FamilyMembersResDto
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • [MERGE] dev to main #162: The new TrafficRemainingBalanceQueryService and Redis balance-read helpers directly depend on the traffic infrastructure (TrafficRedisRuntimePolicy, TrafficQuotaCacheService, TrafficRedisKeyFactory) introduced in that PR.
  • Dev #233: Both PRs modify FamilyMapper.xml's selectFamilyMembers query; this PR adds new result columns (sharedPoolRemainingData, sharedLimitActive) alongside the retrieved PR's query restructuring.
  • Dev to main #228: Both PRs extend traffic/Redis runtime components (TrafficRedisKeyFactory, TrafficRedisRuntimePolicy, TrafficQuotaCacheService); this PR's new balance service depends on those runtime pieces modified in that PR.

Suggested labels

test, traffic-cache, family-service, data-service, redis

Suggested reviewers

  • Iwantcod
  • pjh813
  • Misu0616

Poem

🐰 A rabbit hops through Redis halls,
Balancing caches, answering calls—
DB and cache in harmony dance,
Remaining amounts get their second chance! ✨
Family pools now shine so bright,
Traffic-aware and precise as moonlight! 🌙

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (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.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

@pjh813 pjh813 merged commit edcd645 into main Mar 17, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 버그 관련 feature 새 기능 개발 priority:high 우선순위: 상

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants