mrzmay_eval.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import json
  2. from datetime import datetime, timedelta
  3. def s2t(seconds):
  4. h = seconds//3600
  5. m = seconds%3600//60
  6. s = (seconds%3600)%60
  7. return "{:02.0f}:{:02.0f}:{:02.0f}".format(h, m, s)
  8. f = open("mrzmay.json", "r")
  9. members = json.loads(f.read())
  10. f.close()
  11. dateformat = "%Y-%m-%dT%H:%M:%SZ"
  12. stations = ['EDWW_M__CTR', 'EDUU_O_CTR', 'EDWW_MRZ_CTR', 'EDWW__M_CTR', 'EDWW_M___CTR', 'EDWW_B___CTR', 'EDWW_CTR', 'EDWW_B_CTR', 'EDWW_M_CTR', 'EDWW_B__CTR', 'EDWW_F_CTR', 'EDWW_K_CTR']
  13. for member in members:
  14. member["eval"] = {"sessions": 0, "time": timedelta(seconds=0), "aircraft": 0}
  15. for item in member["data"]["items"]:
  16. if datetime.strptime(item["connection_id"]["start"],dateformat) > datetime.strptime("2024-05-01T00:00:00Z",dateformat) and item["connection_id"]["callsign"] in stations:
  17. member["eval"]["sessions"] += 1
  18. member["eval"]["time"] += (datetime.strptime(item["connection_id"]["end"], dateformat) - datetime.strptime(item["connection_id"]["start"], dateformat))
  19. member["eval"]["aircraft"] += item["aircrafttracked"]
  20. print("{:>7}: Sessions: {:>3}, Online für: {}, Flugzeuge: {:>4}".format(member["name"], member["eval"]["sessions"], s2t(member["eval"]["time"].total_seconds()), member["eval"]["aircraft"]))
  21. totals ={"sessions": 0, "time": timedelta(seconds=0), "aircraft": 0}
  22. for member in members:
  23. totals["sessions"] += member["eval"]["sessions"]
  24. totals["time"] += member["eval"]["time"]
  25. totals["aircraft"] += member["eval"]["aircraft"]
  26. print("=============================================================")
  27. print("{:>7}: Sessions: {:>3}, Online für: {}, Flugzeuge: {:>4}".format("Gesamt", totals["sessions"], s2t(totals["time"].total_seconds()), totals["aircraft"]))