Skip to content

fix #4365 【ユーザーグループ】グループに紐づくユーザーのパフォーマンス改善#4387

Open
kaburk wants to merge 1 commit into
baserproject:5.2.xfrom
kaburk:5.2.x-#4365
Open

fix #4365 【ユーザーグループ】グループに紐づくユーザーのパフォーマンス改善#4387
kaburk wants to merge 1 commit into
baserproject:5.2.xfrom
kaburk:5.2.x-#4365

Conversation

@kaburk
Copy link
Copy Markdown
Collaborator

@kaburk kaburk commented May 22, 2026

よろしくお願いします。

Copilot AI review requested due to automatic review settings May 22, 2026 10:41
Copy link
Copy Markdown
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

ユーザーグループ一覧表示・削除処理における「紐づくユーザー」読み込みを抑制し、不要な関連取得を避けることでパフォーマンス改善を図るPRです。

Changes:

  • ユーザーグループ一覧取得(getIndex())で、設定 BcApp.isDisplayUserListInUserGroup に応じて Userscontain を切り替えるよう変更
  • ユーザーグループ削除(delete())で、関連ユーザー有無の判定を「関連取得」から「中間テーブルの exists チェック」に変更し、読み込みコストを削減
Comments suppressed due to low confidence (1)

plugins/baser-core/src/Service/UserGroupsService.php:111

  • BcApp.isDisplayUserListInUserGroup の値によって getIndex()Userscontain しない分岐が追加されていますが、この設定値を 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])) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants