-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor: DriveFileEntityServiceとDriveFolderEntityServiceの複数件取得をリファクタ #17064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: DriveFileEntityServiceとDriveFolderEntityServiceの複数件取得をリファクタ #17064
Conversation
|
このPRによるapi.jsonの差分 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #17064 +/- ##
============================================
+ Coverage 14.00% 63.18% +49.18%
============================================
Files 237 1154 +917
Lines 11287 115381 +104094
Branches 3733 8019 +4286
============================================
+ Hits 1581 72909 +71328
- Misses 7584 40325 +32741
- Partials 2122 2147 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Backend Memory Usage Comparison
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the DriveFileEntityService and DriveFolderEntityService to optimize batch retrieval operations and prevent N+1 query problems. The changes introduce hint-based packing mechanisms, add packMany methods with pre-fetching strategies, and include comprehensive unit tests to verify the improvements.
Key Changes:
- Introduced utility functions
uniqueByKeyandsplitIdAndObjectsfor efficient deduplication - Added hint parameter support to entity service pack methods to enable pre-fetched data reuse
- Implemented
packMany()method inDriveFolderEntityServicewith ancestor collection and count aggregation - Refactored
packMany()inDriveFileEntityServiceto deduplicate and pre-fetch user and folder data
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/backend/src/misc/unique-by-key.ts |
New utility function to deduplicate items by key |
packages/backend/src/misc/split-id-and-objects.ts |
New utility function to separate IDs from objects |
packages/backend/src/core/entities/DriveFolderEntityService.ts |
Added hint parameter to pack(), new packMany() with batch queries for counts and ancestors |
packages/backend/src/core/entities/DriveFileEntityService.ts |
Added packedFolder hint support, refactored packMany() with pre-fetching and deduplication |
packages/backend/test/unit/entities/DriveFolderEntityService.ts |
New unit tests for pack() and packMany() methods |
packages/backend/test/unit/entities/DriveFileEntityService.ts |
New unit tests covering pack(), packNullable(), and packMany() with mocking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/backend/test/unit/entities/DriveFolderEntityService.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ice.ts" This reverts commit 83bb956.
|
👍🏻 |
What
Why
ファイル/フォルダの数によってはそれなりの数のクエリが飛びそうだったので(N+1の抑止)
Additional info (optional)
Misskeyを実際に動かして確認+テストを追加して確認
Checklist