Files
Aislo/resources/tester/scratch/inspect_linked_const.py
T

46 lines
1.3 KiB
Python

import json
with open('resources/data_work_item_link/work_item_link_2026-01-01.json', 'r', encoding='utf-8') as f:
link_data = json.load(f)
with open('resources/data_work_item_master/const_work_item_master_2026-01-01.json', 'r', encoding='utf-8') as f:
const_master = json.load(f)
# const_master structure
print(f"const_master keys: {list(const_master.keys())}")
items = const_master.get('items', const_master.get('work_items', []))
if isinstance(const_master, list):
items = const_master
print(f"Total const master items: {len(items)}")
item_map = {}
for it in items:
k = it.get('work_item_key') or it.get('key') or it.get('code')
if k:
item_map[k] = it
# Check linked keys
linked_keys = set()
for l in link_data.get('links', []):
ck = l.get('const_key')
if ck:
linked_keys.add(ck)
print(f"Linked keys count: {len(linked_keys)}")
chapters = set()
for k in sorted(linked_keys):
it = item_map.get(k)
if it:
ch = it.get('chapter', '')
sec = it.get('section', '')
name = it.get('name', '')
chapters.add(ch)
print(f"{k}: ch='{ch}', sec='{sec}', name='{name}'")
else:
print(f"{k}: NOT FOUND in master")
print("\n--- Unique Chapters in Linked Keys ---")
for ch in sorted(chapters):
print(ch)