UEFA NL
This commit is contained in:
parent
7946c0c3e1
commit
f0f5370b0b
@ -56,8 +56,6 @@ import matplotlib.pyplot as plt
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
|
|
||||||
|
|
||||||
scenario = Scenario.objects.get(id=9541)
|
scenario = Scenario.objects.get(id=9541)
|
||||||
season = scenario.season
|
season = scenario.season
|
||||||
|
|
||||||
@ -73,7 +71,7 @@ teams_in_group_together = {
|
|||||||
}
|
}
|
||||||
violated_wishes = defaultdict(lambda:{'violations':0,'comments':defaultdict(lambda:0)})
|
violated_wishes = defaultdict(lambda:{'violations':0,'comments':defaultdict(lambda:0)})
|
||||||
violated_blockings = defaultdict(lambda:{'violations':0,'comments':defaultdict(lambda:0)})
|
violated_blockings = defaultdict(lambda:{'violations':0,'comments':defaultdict(lambda:0)})
|
||||||
|
elementary_violations = defaultdict(lambda:defaultdict(lambda:0))
|
||||||
|
|
||||||
for scenario in season.scenarios.all():
|
for scenario in season.scenarios.all():
|
||||||
for conference in Conference.objects.filter(scenario=scenario,display_group=True).order_by('name'):
|
for conference in Conference.objects.filter(scenario=scenario,display_group=True).order_by('name'):
|
||||||
@ -98,6 +96,20 @@ for scenario in season.scenarios.all():
|
|||||||
violated_blockings[b.team]['comments'][f"{b.type} - {b.day}"] += 1
|
violated_blockings[b.team]['comments'][f"{b.type} - {b.day}"] += 1
|
||||||
|
|
||||||
|
|
||||||
|
for key,val in violated_wishes.items():
|
||||||
|
for k,v in val['comments'].items():
|
||||||
|
suffix = ""
|
||||||
|
for i in k.split("<br>"):
|
||||||
|
if i == "":
|
||||||
|
continue
|
||||||
|
elif i in ["1 too many","1 too few"]:
|
||||||
|
suffix = f": {i}"
|
||||||
|
continue
|
||||||
|
elementary_violations[key][f"{i}{suffix}"] += v
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minVal = 999999
|
minVal = 999999
|
||||||
maxVal = 0
|
maxVal = 0
|
||||||
@ -172,7 +184,7 @@ for t1 in teams:
|
|||||||
sol += "<tr>\n"
|
sol += "<tr>\n"
|
||||||
sol += f"<td>{t1.shortname}</td>"
|
sol += f"<td>{t1.shortname}</td>"
|
||||||
for t2 in teams:
|
for t2 in teams:
|
||||||
color = heatmap_color_for((teams_in_group_together[(t1,t2)]-minVal)/((maxVal-minVal) or 1))
|
color = heatmap_color_for((abs(teams_in_group_together[(t1,t2)]-(maxVal+minVal)/2))/((maxVal-minVal)/2 or 1))
|
||||||
if teams_in_group_together[(t1,t2)] == 0:
|
if teams_in_group_together[(t1,t2)] == 0:
|
||||||
color = 'grey'
|
color = 'grey'
|
||||||
val = f"{percentage(teams_in_group_together[(t1,t2)])}"
|
val = f"{percentage(teams_in_group_together[(t1,t2)])}"
|
||||||
@ -193,13 +205,13 @@ sol += "<table id='etable' style='border:5px solid black'>\n"
|
|||||||
sol += "<thead>\n"
|
sol += "<thead>\n"
|
||||||
sol += "<tr>\n"
|
sol += "<tr>\n"
|
||||||
for t in violated_blockings.keys():
|
for t in violated_blockings.keys():
|
||||||
sol += f"<th >{t.shortname}</th>\n"
|
sol += f"<th colspan='2'>{t.shortname}</th>\n"
|
||||||
sol += "</tr>\n"
|
sol += "</tr>\n"
|
||||||
sol += "</thead>\n"
|
sol += "</thead>\n"
|
||||||
sol += "<tbody>\n"
|
sol += "<tbody>\n"
|
||||||
sol += "<tr>\n"
|
sol += "<tr>\n"
|
||||||
for val in violated_blockings.values():
|
for val in violated_blockings.values():
|
||||||
sol += f"<td >{val['violations']} ({percentage(val['violations'])})</td>"
|
sol += f"<td colspan='2'>{val['violations']} ({percentage(val['violations'])})</td>"
|
||||||
sol += "</tr>\n"
|
sol += "</tr>\n"
|
||||||
sol += "<tr>\n"
|
sol += "<tr>\n"
|
||||||
for val in violated_blockings.values():
|
for val in violated_blockings.values():
|
||||||
@ -236,9 +248,9 @@ for val in violated_wishes.values():
|
|||||||
sol += f"<td >{val['violations']} ({percentage(val['violations'])})</td>"
|
sol += f"<td >{val['violations']} ({percentage(val['violations'])})</td>"
|
||||||
sol += "</tr>\n"
|
sol += "</tr>\n"
|
||||||
sol += "<tr>\n"
|
sol += "<tr>\n"
|
||||||
for val in violated_wishes.values():
|
for key,val in violated_wishes.items():
|
||||||
sol += f"<td>"
|
sol += f"<td>"
|
||||||
for c,n in val['comments'].items():
|
for c,n in elementary_violations[key].items():
|
||||||
sol += f"<table style='align:top;border:3px solid white'><tr><td style='width:100%'>{c}</td><td style='text-align: right'>{n} ({percentage(n)})</td></tr></table>"
|
sol += f"<table style='align:top;border:3px solid white'><tr><td style='width:100%'>{c}</td><td style='text-align: right'>{n} ({percentage(n)})</td></tr></table>"
|
||||||
sol += f"</td>"
|
sol += f"</td>"
|
||||||
sol += "</tr>\n"
|
sol += "</tr>\n"
|
||||||
@ -246,13 +258,6 @@ sol += "</tbody>\n"
|
|||||||
sol += "</table>\n"
|
sol += "</table>\n"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
with open(f'analytics.html', 'w') as f:
|
with open(f'analytics.html', 'w') as f:
|
||||||
f.write(sol)
|
f.write(sol)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user