Skip to content

Dev to main#296

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

Dev to main#296
Iwantcod merged 2 commits into
mainfrom
dev

Conversation

@Iwantcod
Copy link
Copy Markdown
Member

@Iwantcod Iwantcod commented Mar 19, 2026

개요

관련 BackLog

Resolves: (Backlog Number, ...)

PR 유형

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

PR Checklist

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

Summary by CodeRabbit

  • New Features

    • Added admin-only endpoint to rehydrate repeat blocks in cache, with detailed success and failure reporting.
  • Improvements

    • Enhanced repeat block time-window evaluation to correctly process intervals crossing midnight between consecutive days.
  • Tests

    • Added test coverage for new admin functionality and repeat block timing edge cases.

@Iwantcod Iwantcod requested a review from pjh813 March 19, 2026 16:59
@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: 7ea932a7-3cd5-4ef1-bc93-8406e5e70116

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8b331 and aeb972b.

📒 Files selected for processing (11)
  • src/main/java/com/pooli/policy/controller/AdminPolicyController.java
  • src/main/java/com/pooli/policy/domain/dto/response/RepeatBlockRehydrateAllResDto.java
  • src/main/java/com/pooli/policy/service/AdminPolicyService.java
  • src/main/java/com/pooli/policy/service/AdminPolicyServiceImpl.java
  • src/main/java/com/pooli/traffic/service/decision/TrafficDbDeductFallbackService.java
  • src/main/java/com/pooli/traffic/service/policy/TrafficPolicyWriteThroughService.java
  • src/main/java/com/pooli/traffic/service/runtime/TrafficRedisKeyFactory.java
  • src/test/java/com/pooli/policy/controller/AdminPolicyControllerWebMvcTest.java
  • src/test/java/com/pooli/policy/service/AdminPolicyServiceImplTest.java
  • src/test/java/com/pooli/traffic/service/decision/TrafficDbDeductFallbackServiceTest.java
  • src/test/java/com/pooli/traffic/service/policy/TrafficPolicyWriteThroughServiceTest.java

📝 Walkthrough

Walkthrough

This PR introduces an admin-only endpoint to rehydrate all repeat blocks from the database into Redis, along with supporting infrastructure for handling midnight-crossing repeat block intervals. The feature includes a new response DTO, service implementation with error handling, updated repeat-block serialization logic, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Admin Endpoint & Response DTO
src/main/java/com/pooli/policy/controller/AdminPolicyController.java, src/main/java/com/pooli/policy/domain/dto/response/RepeatBlockRehydrateAllResDto.java
New admin-protected POST endpoint /repeat-blocks/rehydrate-all and corresponding response DTO capturing total, success, failure counts and failed line IDs with Swagger documentation.
Service Interface & Implementation
src/main/java/com/pooli/policy/service/AdminPolicyService.java, src/main/java/com/pooli/policy/service/AdminPolicyServiceImpl.java
Service interface method added; implementation loads repeat-block Redis keys, fetches blocks from DB, syncs through write-through service, aggregates results with success/failure tracking using private helpers for key parsing and validation.
Traffic Service Updates
src/main/java/com/pooli/traffic/service/decision/TrafficDbDeductFallbackService.java, src/main/java/com/pooli/traffic/service/policy/TrafficPolicyWriteThroughService.java
Enhanced repeat-block evaluation to handle midnight-crossing intervals by splitting them into "today" and "next day" hash entries; isRepeatBlocked now accepts both current and previous day-of-week parameters.
Redis Key Utilities
src/main/java/com/pooli/traffic/service/runtime/TrafficRedisKeyFactory.java
Two new public methods added: repeatBlockKeyPattern() for wildcard matching and repeatBlockKeyPrefix() for parsing lineIds from repeat-block keys.
Test Coverage
src/test/java/com/pooli/policy/controller/AdminPolicyControllerWebMvcTest.java, src/test/java/com/pooli/policy/service/AdminPolicyServiceImplTest.java, src/test/java/com/pooli/traffic/service/decision/TrafficDbDeductFallbackServiceTest.java, src/test/java/com/pooli/traffic/service/policy/TrafficPolicyWriteThroughServiceTest.java
New Spring MVC slice test for controller auth (admin success/user forbidden), service unit tests covering success/failure aggregation and error cases, and traffic service tests validating midnight-crossing interval handling.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin User
    participant Controller as AdminPolicyController
    participant Service as AdminPolicyServiceImpl
    participant Redis as Redis
    participant DB as Database
    participant WriteThrough as TrafficPolicyWriteThroughService
    
    Admin->>Controller: POST /repeat-blocks/rehydrate-all
    activate Controller
    Controller->>Service: rehydrateAllRepeatBlocksToRedis()
    activate Service
    
    Service->>Redis: KEYS repeat_block:*
    Redis-->>Service: matching keys
    Service->>Service: Parse lineIds from keys
    
    loop for each lineId
        Service->>DB: Fetch repeat blocks by lineId
        DB-->>Service: repeat blocks list
        Service->>WriteThrough: syncRepeatBlockUntracked(lineId, blocks, version)
        activate WriteThrough
        WriteThrough->>Redis: Write/update repeat block hashes
        WriteThrough-->>Service: PolicySyncResult
        deactivate WriteThrough
        Service->>Service: Track success/failure
    end
    
    Service-->>Service: Build response (counts + failed IDs)
    Service-->>Controller: RepeatBlockRehydrateAllResDto
    deactivate Service
    Controller-->>Admin: HTTP 200 + response body
    deactivate Controller
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • [MERGE] dev to main #162: Modifies TrafficRedisKeyFactory repeat-block key methods and TrafficPolicyWriteThroughService sync logic that are core dependencies for the new rehydrate feature.
  • [Merge] Dev to Main #135: Updates AdminPolicyServiceImplTest file with overlapping test infrastructure and annotations.
  • Dev #158: Modifies AdminPolicyServiceImpl with concurrent changes to the same service class structure.

Suggested labels

feature, test, priority: medium

Suggested reviewers

  • pjh813
  • Misu0616
  • hyeonRS

Poem

🐰 Repeat blocks now dance through Redis time,
Midnight crossings split by design sublime,
Admin rehydrates with careful count,
Success and failure fully mount,
Testing ensures no hop goes awry! ✨

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

@Iwantcod Iwantcod merged commit e0c6a02 into main Mar 19, 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants