Skip to content

[Fix] 폴더 통째 삭제 전 개별 삭제됐던 자료가 폴더 복구 시 함께 부활하던 문제 수정 - #141

Merged
Mymyseoyoung merged 2 commits into
mainfrom
fix/trash-folder-material-resurrects-on-restore
Aug 11, 2026
Merged

Mymyseoyoung merged 2 commits into
mainfrom
fix/trash-folder-material-resurrects-on-restore

Conversation

@EH-OI

@EH-OI EH-OI commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

폴더를 통째로 삭제했다가 복구할 때, 그 폴더 삭제 이전에 이미 개별적으로 휴지통에 있던 자료까지 함께 부활하던 문제를 수정했습니다. (PR #140의 후속 수정)

변경 사항

  • trashMaterialsByFolder에 deletedAt 파라미터 추가 — DB의 CURRENT_TIMESTAMP 대신 폴더 자신의 삭제 시각을 그대로 넘겨받아 저장, 캐스케이드 삭제된 자료를 명확히 식별 가능하게 함
  • restoreTrashedMaterialsByFolder, countDeletedByFolderIdAndUserId, PR #140의 countDeletedByFolderIdsAndUserId에 material.deleted_at >= folder.deleted_at 조건 추가 — 폴더보다 먼저 삭제된 자료는 복구/카운트 대상에서 제외
  • 휴지통 폴더 상세 목록(findTrashedByFolderIdOrderByDeletedAtDesc/Asc)도 동일 기준 적용 — 폴더 카드의 개수와 상세 목록 개수가 항상 일치하도록
  • 휴지통 최상단 자료 탭(findTrashedByUserIdOrderByDeletedAtDesc/Asc)은 반대로 조건을 완화 — 폴더가 같이 삭제됐어도 그 폴더보다 먼저 개별 삭제된 자료는 계속 노출되도록 함 (안 그러면 그 자료들이 휴지통 어디에도 안 보이는 새 문제가 생김)
  • FolderService.moveFolderToTrash()가 새 시그니처에 맞춰 folder.getDeletedAt()을 넘기도록 수정
  • MaterialRepositoryTest에 회귀 테스트 2건 추가

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [ ]

Summary by CodeRabbit

  • 버그 수정

    • 폴더와 함께 삭제된 자료만 정확히 집계·복구되도록 개선했습니다.
    • 폴더 삭제 전 개별 삭제된 자료가 잘못 복구되지 않도록 수정했습니다.
    • 휴지통 조회, 자료 수 집계 및 복구에 동일한 삭제 시점을 적용했습니다.
    • 휴지통에 없는 폴더의 복구 요청을 안전하게 처리합니다.
  • 테스트

    • 폴더 및 자료 삭제·복구 시점 관련 회귀·통합 테스트를 추가했습니다.

@EH-OI

EH-OI commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai rate limit

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Your plan includes PR reviews subject to rate limits. More reviews will be available in 2 minutes.

@EH-OI

EH-OI commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: affdb0eb-eb65-4744-babf-b180d691fea0

📥 Commits

Reviewing files that changed from the base of the PR and between c5e616e and 98ba034.

📒 Files selected for processing (7)
  • src/main/java/com/teaching/backend/domain/folder/service/FolderService.java
  • src/main/java/com/teaching/backend/domain/material/repository/MaterialRepository.java
  • src/main/java/com/teaching/backend/domain/trash/service/TrashService.java
  • src/test/java/com/teaching/backend/domain/folder/service/FolderRestoreIntegrationTest.java
  • src/test/java/com/teaching/backend/domain/folder/service/FolderServiceTest.java
  • src/test/java/com/teaching/backend/domain/material/repository/MaterialRepositoryTest.java
  • src/test/java/com/teaching/backend/domain/trash/service/TrashServiceTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/test/java/com/teaching/backend/domain/material/repository/MaterialRepositoryTest.java
  • src/main/java/com/teaching/backend/domain/material/repository/MaterialRepository.java

📝 Walkthrough

Walkthrough

폴더 삭제 시각을 연결된 자료의 휴지통 처리에 전달합니다. 휴지통 조회, 복구, 자료 수 집계 및 상세 조회는 자료와 폴더의 삭제 시각을 비교합니다. 관련 단위 테스트와 통합 테스트를 추가했습니다.

Changes

폴더 휴지통 자료 처리

Layer / File(s) Summary
삭제 시각 전달 및 저장
src/main/java/com/teaching/backend/domain/folder/service/FolderService.java, src/main/java/com/teaching/backend/domain/material/repository/MaterialRepository.java
FolderService가 폴더의 deletedAt을 trashMaterialsByFolder에 전달합니다. 자료의 deleted_at과 updated_at은 해당 시각으로 저장됩니다.
휴지통 조회·복구·집계 필터
src/main/java/com/teaching/backend/domain/material/repository/MaterialRepository.java, src/main/java/com/teaching/backend/domain/folder/service/FolderService.java, src/main/java/com/teaching/backend/domain/trash/service/TrashService.java
자료와 폴더의 삭제 시각을 비교합니다. 폴더 복구는 폴더 삭제 시각 이후 함께 삭제된 자료만 처리합니다. 삭제 시각을 조회하지 못한 폴더는 복구 대상에서 건너뜁니다.
삭제 시각 기준 검증
src/test/java/com/teaching/backend/domain/material/repository/MaterialRepositoryTest.java, src/test/java/com/teaching/backend/domain/folder/service/FolderRestoreIntegrationTest.java, src/test/java/com/teaching/backend/domain/folder/service/FolderServiceTest.java, src/test/java/com/teaching/backend/domain/trash/service/TrashServiceTest.java
폴더 삭제 전 개별 삭제된 자료가 집계와 복구에서 제외되는지 검증합니다. 단일 및 일괄 폴더 복구도 검증합니다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: m00nsh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 폴더 삭제 전에 개별 삭제된 자료가 폴더 복구 시 함께 복구되는 문제를 정확히 설명하며, 변경 사항의 핵심을 간결하게 요약합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/trash-folder-material-resurrects-on-restore

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/teaching/backend/domain/material/repository/MaterialRepository.java`:
- Around line 247-254: Update the folder restoration flow involving
restoreTrashedMaterialsByFolder so materials are restored before the folder’s
deleted_at is cleared, or pass the folder’s original deletion timestamp into the
query. Ensure the material filter compares against a non-null folder deletion
time so materials deleted with the folder are restored.
🪄 Autofix

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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5746f310-9b1f-4a78-82f6-4d48f404fb25

📥 Commits

Reviewing files that changed from the base of the PR and between 542015b and c5e616e.

📒 Files selected for processing (3)
  • src/main/java/com/teaching/backend/domain/folder/service/FolderService.java
  • src/main/java/com/teaching/backend/domain/material/repository/MaterialRepository.java
  • src/test/java/com/teaching/backend/domain/material/repository/MaterialRepositoryTest.java

@EH-OI

EH-OI commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai rate limit

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Your plan includes PR reviews subject to rate limits. Reviews are available now.

@EH-OI

EH-OI commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mymyseoyoung
Mymyseoyoung merged commit 2655b9e into main Aug 11, 2026
2 checks passed
@Mymyseoyoung Mymyseoyoung changed the title fix: 폴더 통째 삭제 전 개별 삭제됐던 자료가 폴더 복구 시 함께 부활하던 문제 수정 [Fix] 폴더 통째 삭제 전 개별 삭제됐던 자료가 폴더 복구 시 함께 부활하던 문제 수정 Aug 12, 2026
@EH-OI EH-OI added the 🪛fix 버그 수정 label Aug 13, 2026
@EH-OI
EH-OI deleted the fix/trash-folder-material-resurrects-on-restore branch August 13, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪛fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants