Skip to content

Dev to Main#212

Closed
Misu0616 wants to merge 6 commits into
mainfrom
dev
Closed

Dev to Main#212
Misu0616 wants to merge 6 commits into
mainfrom
dev

Conversation

@Misu0616
Copy link
Copy Markdown
Contributor

@Misu0616 Misu0616 commented Mar 13, 2026

개요

  1. 활성화 정책 조회 api 수정
  2. mongo db에 정책 차단, 관리자 정책 변경 이력 저장

관련 BackLog

Resolves: (518)

PR 유형

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

PR Checklist

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

Summary by CodeRabbit

  • New Features

    • API responses now include updatedAt timestamps for policies and categories.
    • Added comprehensive policy operation history tracking to capture create, update, and delete events.
    • Adjusted default maximum daily data limit from 100 to 50 units when unset.
  • Tests

    • Updated test coverage to support new history logging and tracking dependencies.

@Misu0616 Misu0616 requested review from Iwantcod and pjh813 March 13, 2026 02:16
@Misu0616 Misu0616 self-assigned this Mar 13, 2026
@Misu0616 Misu0616 added feature 새 기능 개발 refactor 리팩토링 test 테스트 labels Mar 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 13, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a MongoDB-backed audit logging system for policy operations. It adds a PolicyHistory entity and service to record create/update/delete events on policies and categories, updates response DTOs to include updatedAt timestamps, and integrates history logging throughout both admin and user policy services.

Changes

Cohort / File(s) Summary
Response DTOs with updatedAt
src/main/java/com/pooli/policy/domain/dto/response/AdminPolicyActiveResDto.java, AdminPolicyCateResDto.java, AdminPolicyResDto.java
Added updatedAt LocalDateTime field with Swagger schema annotations to capture policy/category update timestamps. Imports updated to include LocalDateTime and clarified Lombok annotations.
Policy History Infrastructure
src/main/java/com/pooli/policy/domain/entity/PolicyHistory.java, src/main/java/com/pooli/policy/repository/PolicyHistoryRepository.java
New MongoDB document entity and repository for persisting policy change events. PolicyHistory captures table name, timestamp, targetId, userId, lineId, event type, and update details with nested UpdateDetail inner class.
Policy History Service
src/main/java/com/pooli/policy/service/PolicyHistoryService.java, PolicyHistoryServiceImpl.java
New service interface and implementation to log policy operations. Implementation includes recursive diff calculation for UPDATE events and object-to-map conversion via ObjectMapper, with error handling and user context extraction from security context.
Admin Policy Service Integration
src/main/java/com/pooli/policy/service/AdminPolicyServiceImpl.java
Integrated PolicyHistoryService dependency and history logging across create/update/delete operations for policies and categories. Added DB re-reads to return fresh updatedAt timestamps instead of builder-based responses.
User Policy Service Integration
src/main/java/com/pooli/policy/service/UserPolicyServiceImpl.java
Extensive integration of PolicyHistoryService logging across RepeatBlockPolicy, ImmediateBlockPolicy, LineLimit, and AppPolicy workflows. Updated getAppliedPolicies to return enhanced response including limitPolicy and appPolicyList; adjusted maxDailyData default from 100L to 50L.
Test Updates
src/test/java/com/pooli/policy/service/UserPolicyServiceImplTest.java
Added mocks for PolicyHistoryService and TrafficPolicyWriteThroughService via ObjectProvider. Updated test setup and assertions in getAppliedPolicies\_success and related tests to validate new history logging and response structure changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PolicyService as Admin/User<br/>PolicyService
    participant HistoryService as PolicyHistoryService
    participant Repository as PolicyHistory<br/>Repository
    participant MongoDB

    Client->>PolicyService: Create/Update/Delete Policy
    PolicyService->>PolicyService: Process operation
    PolicyService->>HistoryService: log(tableName, event, targetId,<br/>before, after)
    HistoryService->>HistoryService: calculateDetails(event, before, after)<br/>Extract user from security context
    HistoryService->>Repository: save(PolicyHistory entity)
    Repository->>MongoDB: persist document
    MongoDB-->>Repository: acknowledged
    Repository-->>HistoryService: saved entity
    HistoryService-->>PolicyService: history logged
    PolicyService-->>Client: response with updatedAt
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Dev #158: Modifies AdminPolicyServiceImpl and related test files with overlapping admin policy service logic.
  • Dev를 main으로 merge #160: Modifies the same test class (UserPolicyServiceImplTest) with mock dependency setup and assertion updates.
  • Dev to main #202: Modifies UserPolicyServiceImpl's app-policy creation and toggle flow affecting alarm and history invocations.

Suggested reviewers

  • pjh813

🐰 A new audit trail takes shape,
MongoDB captures each escape,
History whispers what changed when,
From DELETE to CREATE again! ✨📝

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title "Dev to Main" is generic and does not describe the actual changes. It merely indicates a branch merge without conveying the main feature (policy history persistence to MongoDB). Replace with a specific, descriptive title such as "Add MongoDB policy history tracking for admin and user policy operations" that clearly summarizes the primary changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 4.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • 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.

@Misu0616 Misu0616 closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 새 기능 개발 refactor 리팩토링 test 테스트

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant