import json, os, time, collections

P = '/Users/liuxinyuan/Desktop/Hermes输出-工作类/数据/activities_feishu.json'
a = json.load(open(P, encoding='utf-8'))
items = a['items']
print('generated =', a.get('generated'), '| total =', a.get('total'), '| months =', a.get('months'))
print('channel_breakdown =', json.dumps(a.get('channel_breakdown'), ensure_ascii=False))
print('owner_merge =', json.dumps(a.get('owner_merge'), ensure_ascii=False))
print('note =', a.get('note'))
print('n =', len(items))
print('channel:', collections.Counter(str(x.get('channel') or '') for x in items).most_common(8))
print('atype :', collections.Counter(str(x.get('atype') or '') for x in items).most_common(8))
print('dept  :', collections.Counter(str(x.get('dept_raw') or '') for x in items).most_common(8))
print('sales :', len(set(x.get('sales') for x in items)), '人 |', '黄明月:', sum(1 for x in items if x.get('sales') == '黄明月'), '张立娅:', sum(1 for x in items if x.get('sales') == '张立娅'), '刘子研:', sum(1 for x in items if x.get('sales') == '刘子研'))
print('months present:', sorted(set(str(x.get('date') or '')[:7] for x in items)))
print('no-channel:', sum(1 for x in items if not x.get('channel')), '| no-customer:', sum(1 for x in items if not x.get('customer')))
print('sample:', json.dumps(items[0], ensure_ascii=False)[:300])
