fix #4365 【ユーザーグループ】グループに紐づくユーザーのパフォーマンス改善#4387
Open
kaburk wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
ユーザーグループ一覧表示・削除処理における「紐づくユーザー」読み込みを抑制し、不要な関連取得を避けることでパフォーマンス改善を図るPRです。
Changes:
- ユーザーグループ一覧取得(
getIndex())で、設定BcApp.isDisplayUserListInUserGroupに応じてUsersのcontainを切り替えるよう変更 - ユーザーグループ削除(
delete())で、関連ユーザー有無の判定を「関連取得」から「中間テーブルの exists チェック」に変更し、読み込みコストを削減
Comments suppressed due to low confidence (1)
plugins/baser-core/src/Service/UserGroupsService.php:111
BcApp.isDisplayUserListInUserGroupの値によってgetIndex()がUsersをcontainしない分岐が追加されていますが、この設定値をfalseにした場合に「Users がプリロードされない」ことを確認するテストが既存testGetIndex()では担保できていません。回帰防止のため、設定を切り替えた上で結果エンティティにusersが含まれない(例:has('users')が false になる)ことを検証するテスト追加を検討してください。
'exclude_admin' => false,
'order' => null,
'contain' => Configure::read('BcApp.isDisplayUserListInUserGroup') ? ['Users'] : [],
], $queryParams);
$query = $this->UserGroups->find($queryParams['finder']);
if($queryParams['contain']) {
$query->contain($queryParams['contain']);
| $userGroup = $this->UserGroups->get($id); | ||
| /** @var \Cake\ORM\Association\BelongsToMany $assoc */ | ||
| $assoc = $this->UserGroups->getAssociation('Users'); | ||
| if ($assoc->junction()->exists(['user_group_id' => $id])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
よろしくお願いします。