Skip to content

Conversation

@samunohito
Copy link
Member

@samunohito samunohito commented Jan 3, 2026

What

  • DriveFileEntityService
    • withUser: false時のuserEntityService.packMany()カラ打ちを抑止
    • packNullableのhintにfolderも引き込めるように
    • packMany()の事前取得処理で主キーの重複を極力排除してから関連情報を集めるように
    • unit-testの追加
  • DriveFolderEntityService
    • pack()にhintを引き込めるように
    • pack()の動きを踏襲したpackMany()を新設
    • unit-testの追加

Why

ファイル/フォルダの数によってはそれなりの数のクエリが飛びそうだったので(N+1の抑止)

Additional info (optional)

Misskeyを実際に動かして確認+テストを追加して確認

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md ※リファクタなので
  • (If possible) Add tests

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

このPRによるapi.jsonの差分
差分はありません。
Get diff files from Workflow Page

@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 98.26087% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.18%. Comparing base (404fca6) to head (68e2be8).
⚠️ Report is 21 commits behind head on develop.

Files with missing lines Patch % Lines
...kend/src/core/entities/DriveFolderEntityService.ts 97.20% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

Backend Memory Usage Comparison

Metric base head Diff
RSS 358.48 MB 357.82 MB -.66 MB (-.18%)

See workflow logs for details

Copy link
Contributor

Copilot AI left a 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 uniqueByKey and splitIdAndObjects for efficient deduplication
  • Added hint parameter support to entity service pack methods to enable pre-fetched data reuse
  • Implemented packMany() method in DriveFolderEntityService with ancestor collection and count aggregation
  • Refactored packMany() in DriveFileEntityService to 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.

@samunohito samunohito marked this pull request as ready for review January 3, 2026 07:46
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 3, 2026
@syuilo syuilo merged commit f6fc78f into misskey-dev:develop Jan 6, 2026
39 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in [実験中] 管理用 Jan 6, 2026
@syuilo
Copy link
Member

syuilo commented Jan 6, 2026

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages/backend:test packages/backend Server side specific issue/PR size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Development

Successfully merging this pull request may close these issues.

2 participants