import json, os, time, collections

D = '/Users/liuxinyuan/Desktop/Hermes输出-工作类/数据'


def report(name, path):
    print('=' * 60)
    print(name, '|', path)
    print('  size = %.1f MB' % (os.path.getsize(path) / 1024.0 / 1024.0),
          '| mtime =', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.path.getmtime(path))))
    return json.load(open(path, encoding='utf-8'))


# ── 3a activities_feishu.json
a = report('3a activities_feishu.json', os.path.join(D, 'activities_feishu.json'))
print('  top keys:', list(a.keys()) if isinstance(a, dict) else 'LIST')
items = a.get('items') if isinstance(a, dict) else a
print('  n =', len(items), '| updated =', (a.get('updated') or a.get('updated_at')) if isinstance(a, dict) else None)
print('  item keys:', list(items[0].keys()))
tc = collections.Counter(str(it.get('活动类型') or '') for it in items)
print('  活动类型:', tc.most_common(8))
dates = sorted(set(str(it.get('创建时间') or '')[:7] for it in items))
print('  月份:', dates)
dept = collections.Counter(str(it.get('跟进部门') or '') for it in items)
print('  跟进部门:', dept.most_common(8))
cr = collections.Counter(str(it.get('创建者') or '') for it in items)
print('  黄明月/张立娅 残留:', cr.get('黄明月', 0), cr.get('张立娅', 0), '| 刘子研:', cr.get('刘子研', 0))

# ── 3b daily_activities_mcp.json
b = report('3b daily_activities_mcp.json', os.path.join(D, 'daily_activities_mcp.json'))
bitems = b.get('items') or []
print('  n =', len(bitems), '| updated =', b.get('updated'), '| total field =', b.get('total'))
print('  item keys:', list(bitems[0].keys()))
win = [x for x in bitems if str(x.get('start_time') or '')[:10] >= '2026-07-01']
print('  窗口内(>=2026-07-01) =', len(win))
typed_win = sum(1 for x in win if isinstance(x.get('field_76654e'), dict) and x['field_76654e'].get('label'))
print('  窗口内活动类型已填: %d / %d (%.1f%%)' % (typed_win, len(win), 100.0 * typed_win / max(1, len(win))))
print('  窗口内类型分布:', collections.Counter((x.get('field_76654e') or {}).get('label', '') for x in win).most_common(6))
print('  样例:', json.dumps(win[0], ensure_ascii=False)[:400])
