admin: eager-load the relations Filament tables resolve per row

オープン
#223 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
laravel, php

調査の方向性

Start with GroupResource.php:88, TermsDocumentVersionResource.php:72,82, and AuditLogResource.php:88 to trace the per-row relation reads and the table queries that load each record. Then inspect UserResource.php:162,165 and the two model methods it calls, since making those methods use loaded relations affects other callers. Add eager loading for the first three resources and settle on safe behavior for the user methods; done when rendering these tables avoids per-row relation queries and the affected behavior is covered.

索引モデルが issue の本文から書いたものです。

説明

Context

Several admin tables resolve a relation inside a per-row ->state() closure with no eager loading, so each rendered row issues its own query.

Found while fixing #190, where two relation managers had the same defect. Those two are fixed; this is the rest of the panel.

Affected

File Per-row relation
GroupResource.php:88 $record->createdByUser?->fullName() — no getEloquentQuery or modifyQueryUsing at all
TermsDocumentVersionResource.php:72,82 $record->document?->name and createdByUser, likewise nothing
AuditLogResource.php:88 $presenter->actorName($record)
UserResource.php:162,165 hasAcceptedCurrentTerms() and latestAcceptedTermsVersion()

The first three are one with([...]) each.

UserResource is not. latestAcceptedTermsVersion() runs termsAcceptances()->with('acceptedVersion')->latest()->first(), so it is two queries per row — and the inner ->with() makes it look eager-loaded at the call site while the outer query is per-row. Fixing it means making those model methods read a loaded relation instead of querying, which changes behaviour for every other caller. That deserves a decision, not a one-liner.

Why one ticket rather than fixing them as they turn up

The finding that produced this was itself "fixed two, left the third". Handling them one relation manager at a time is how it got to four.

Note

Relations expressed as dotted column names (compartment.lockerBank.name) are visible; the same hop inside a ->state() closure is not. That is why these survived — worth knowing when adding a column.

主要言語
PHP
スター
26
フォーク
2
平均マージ
2日 14時間
マージ済み PR(30日)
14

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Open-Locker/Open-Locker のほかの issue

Open-Locker/Open-Locker の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。