feat(web): CFItemType の逆参照「この種別の項目」を追加#13
Merged
Conversation
CFSubject の逆参照と同じ枠組みを CFItemType に展開。種別詳細ページ/ツリー
ペインに「この種別の項目」を表示する。スコープは案B(単独ページ=テナント横断/
ペイン=現ドキュメント)。種別は FK(cf_item.cf_item_type_id)なので JSONB/GIN
不要で軽い。
- repo: list_items_by_item_type / count_items_by_item_type(FK・document_id
スコープ)。共通の select/count を _list_items_where / _count_items_where に抽出
- web.py: _detail_extras に CFItemType 分岐(item_type_items)、両ペイン経路、
/item-type/{id}/items フラグメントルート、_items_fragment_ctx ヘルパー
- template: subject_items.html を items_endpoint 引数化して subject/item-type 共用、
resource_detail.html に CFItemType セクション追加
- i18n: item_type_items_label(この種別の項目 / Items of this type)
- tests: tests/unit/test_item_type_items.py(FK絞り込み・doc スコープ・ページング・
ペイン表示・もっと見る URL・fragment 検証)8件
- docs: web-ui.md(CFItemType 逆参照の節+総まとめ表に行追加)
CFConcept/License は同FKパターンで将来追加可(現状データ無し)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXFogp18twGiPFBAZcqJw2
CFItemType 逆参照の tenant-wide クエリが seq-scan になるのを防ぐ。 Postgres は FK 列に索引を自動生成しないため「FK だから軽い」は誤りだった。 - migration e2b3c4d5f6a7(down_revision d1a2b3c4e5f6) - cf_item.py __table_args__ に Index をミラー - web-ui.md の「索引不要」記述を btree 索引ありに訂正 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.
概要
CFSubject の逆参照(「この分野を設定している項目」)と同じ枠組みを CFItemType に展開します。種別(CFItemType)の詳細ページ/ツリーペインに「この種別の項目」一覧を表示します。
きっかけ:ユーザーが種別ページを開いても一覧が出ないことに気づいた(逆参照が CFSubject 専用だったため)。種別は FK(
cf_item.cf_item_type_id)なので JSONB/GIN 不要で軽い。実装
list_items_by_item_type/count_items_by_item_type(FK 一致・document_idスコープ)。共通の select/count を_list_items_where/_count_items_whereに抽出して subject と共用。_detail_extrasにCFItemType分岐(item_type_items)、両ペイン経路(SSR deep-link / HTMX フラグメント)で doc スコープ計算、GET /{tenant}/item-type/{id}/itemsフラグメントルート、_items_fragment_ctxヘルパー。subject_items.htmlをitems_endpoint引数化して subject / item-type 共用、resource_detail.htmlに CFItemType セクション追加。item_type_items_label(この種別の項目 / Items of this type)。スコープ(案B・CFSubject と同一)
/uri/{item-type}ページ … テナント横断テスト(8件 / 全704 pass)
FK 絞り込み・除外、doc スコープ、ページング、
_detail_extrasの doc 有無、ペインフラグメント表示、「もっと見る」URL が/item-type/.../items、fragment 検証(非 ItemType→404・bad UUID→400)。ドキュメント
web-ui.md:CFItemType 逆参照の節+「どの情報がどの画面に出るか」総まとめ表に行追加。CFConcept / CFLicense は同 FK パターンで将来追加可(現状データ無し)。Grouping は項目でなく関連を列挙するため別形。
🤖 Generated with Claude Code