# from G254
import json
from pathlib import Path
from island.match import Match
from island.matches import Matches

result = 0
count = 0
ma,mi=0,1000

ms = Matches('wos-data-2022-1')
# ms = Matches.from_profile_expr(lambda r: True)
for m in ms.data:
    l = len(m.query('player', 'join').where(lambda x: 'bot' not in x or x['bot'] == False).select('pid').raw_data)
    print(f"{m.name} => players: {l} game-end-at: {int(m.query('game', 'created').first()['info']['game_end_at'])}")
    ma = max([ma,l])
    mi = min([mi,l])
    result += l
    count += 1
print(ma,mi)

print(result)
print("participants: %d, matches: %d, avg: %f" % (result, count, result / count))
# 146 users
# casual: 324
# new(254-354, 全国复杂网络大会): 205
# new-2(375-421, 无交流): 320
# new-3(426-440, 有交流): 203
# new-4(443-472, 经典模式，无交流): 230
# new-5(474-，经典模式，有交流): 286
# total: 1244, 81, 15.35
# lab: 1039, 69, 15.05
