import datetime,statistics as st
exec(open('analyze.py').read())
tz=datetime.timezone(datetime.timedelta(hours=9))
for r in rows: r['t']=r['t'].replace(tzinfo=tz)
PUB={'B1':datetime.datetime(2026,9,14,9,0,tzinfo=tz),'B2':datetime.datetime(2026,10,3,23,15,tzinfo=tz),'B5':datetime.datetime(2026,10,9,10,20,tzinfo=tz)}
PUB['B3']=PUB['B4']=PUB['B2']
G=[('9/14 公開（50件・手動リクエストあり）',('B1',)),('10/3 公開（374件）',('B2','B3','B4')),('10/9 公開（361件）',('B5',))]
BOTS=[('Googlebot','googlebot'),('Bingbot','bingbot'),('GoogleOther','googleother'),('ShapBot','shapbot'),('ClaudeBot','claudebot'),
      ('meta-externalagent','meta-externalagent'),('Amazonbot','amazonbot'),('MJ12bot','other:MJ12bot'),('SemrushBot','semrushbot'),('serpstatbot','other:serpstatbot')]
def fmt(h):
    return f'{h:.1f}時間' if h<48 else f'{h/24:.1f}日'
print('| クローラ | '+' | '.join(g for g,_ in G)+' |'); print('|---'*(len(G)+1)+'|')
for lab,b in BOTS:
    cells=[]
    for _,bs in G:
        tot=sum(1 for x in L.values() if x['batch'] in bs)
        f={}
        for r in rows:
            if r['n']==b and ischome(r['path']) and r['path'] in L and L[r['path']]['batch'] in bs:
                h=(r['t']-PUB[L[r['path']]['batch']]).total_seconds()/3600
                if h>=0: f[r['path']]=min(f.get(r['path'],1e9),h)
        if not f: cells.append('—（0件）'); continue
        hs=sorted(f.values())
        cells.append(f'{fmt(hs[0])}／{fmt(st.median(hs))}（{len(hs)}/{tot}）')
    print(f'| {lab} | '+' | '.join(cells)+' |')
