#!/usr/bin/env python3
"""Show group distribution"""
import json
from collections import Counter

with open('/root/gov_crawler/daily_crawl_config.json', 'r') as f:
    items = json.load(f)

groups = Counter()
for c in items:
    g = c.get('group', '(无分组)')
    groups[g] += 1

print(f"Total: {len(items)} configs in {len(groups)} groups\n")

# Sort by count desc
for g, cnt in groups.most_common():
    bar = '█' * min(cnt // 2, 50)
    print(f"  {g:16s} {cnt:4d} {bar}")

print(f"\nGroups without province/企业/全国/环评等:")
target = ['环评', '政府公告', '区县', '其他', '生态环境']
left = [c for c in items if c.get('group', '') in target]
print(f"  Remaining generic groups: {len(left)} entries")
for c in left:
    print(f"    [{c['group']}] {c['name']}")
