feat(web): 分野詳細に「この分野を設定している項目」逆参照を追加#11
Merged
Conversation
分野の逆引き(この分野を設定している項目)で使う JSONB 包含クエリ
subject_uri @> '[{"identifier": ...}]' を高速化する GIN(jsonb_path_ops)
索引を追加。大規模フレームワークでも seq scan を避ける。
- migration d1a2b3c4e5f6(down_revision c704faa62b4f)
- cf_item.py の __table_args__ に同索引をミラー(autogenerate 整合)
- db-schema.md(英/日)の cf_item 索引一覧に追記
逆引き機能(router/template)は後続 PR。索引のみ先行。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXFogp18twGiPFBAZcqJw2
CFSubject 詳細ページ(/uri/{subject})に、同一テナント内でこの分野を
subjectURI で参照している CFItem の一覧を表示する。上位20件をSSR、件数表示、
「もっと見る」で HTMX フラグメント(/{tenant}/subject/{id}/items)から次ページを
自己再帰的に追記(ツリーの遅延ロードと同作法)。
- cf_item_repository: list_items_by_subject / count_items_by_subject
(subject_uri @> 包含・GIN索引利用・テナントスコープ・安定ソート・ページング)
- web.py: _detail_extras に CFSubject 分岐、subject_items を _DETAIL_EXTRAS_KEYS
と pane_extras 両方に追加、subject_items_fragment ルート(CFSubject 検証・
limit+1 で has_more 判定・Cache-Control フラグメント)
- 再利用フラグメント fragments/subject_items.html(SSR include と HTMX 両用)、
resource_detail.html の lookup 分岐に CFSubject ゲートで挿入
- i18n: subject_items_label / subject_items_count / show_more
- tests: unit(包含/テナントスコープ/ページング/count/空)+ integration
(分野ページ/フラグメント/検証404・400/cache/空状態)計13件
- docs: web-ui.md(分野逆参照節・フラグメントルート)
テナント内のみ(分野はテナント所有)。subject 文字列のみの参照は対象外。
GIN索引は先行PR、デモデータ(subjectURI付与)は別途対応。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XXFogp18twGiPFBAZcqJw2
CFSubject をツリーの Definitions からクリックして右ペインに開いたとき、 _pane_fragment_response が _detail_extras を普通に呼ぶため「この分野を設定して いる項目」が出てしまっていた(初期SSRの pane_extras では空にしていたが、HTMX ペイン更新経路が漏れていた)。 _detail_extras に include_subject_items 引数を追加し、ペイン経路(in_pane)では False を渡して計算自体を抑止(テンプレ条件だけでなくクエリも走らせない)。 単独 /uri/ ページのみ表示する。 - 回帰テスト2件追加(_detail_extras のフラグ挙動 / ペインフラグメントで非表示) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XXFogp18twGiPFBAZcqJw2
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(分野)詳細ページに、同一テナント内でこの分野を
subjectURIで参照している CFItem の一覧を表示します(CFItem→CFSubject の逆引き)。上位20件を SSR、件数表示、「もっと見る」で次ページを HTMX で自己再帰的に追記(案A:別ページに飛ばさない)。実装
cf_item_repository:list_items_by_subject/count_items_by_subject—subject_uri @> '[{"identifier": ...}]'包含クエリ(GIN索引ix_cf_items_subject_uri_ginを使用=EXPLAIN で Bitmap Index Scan 確認済み)、テナントスコープ、安定ソート、offset ページング。web.py:_detail_extrasにCFSubject分岐(include_subject_items引数で右ペインでは計算・表示を抑止)、subject_itemsを_DETAIL_EXTRAS_KEYSとpane_extras両方に追加、GET /{tenant}/subject/{id}/itemsフラグメントルート(CFSubject 検証・limit+1で has_more・Cache-Control: 86400)。fragments/subject_items.html(SSR include と HTMX 両用)、resource_detail.htmlの lookup 分岐にCFSubjectゲートで挿入。subject_items_label/subject_items_count/show_more(en/ja)。スコープ
subjectURI参照のみ(subject文字列のみは対象外)、subject のみ、ツリー右ペインでは非表示(ドキュメントスコープ・Codex P2 対応)。テスト(計15件 / 全692 pass)
_detail_extrasのinclude_subject_items挙動 / ペインフラグメントで非表示。ドキュメント
docs/spec/web-ui.md: 分野逆参照節・フラグメントルート。デモ実データ用の subjectURI 付与は別途対応。
🤖 Generated with Claude Code