From 0284c755ae01c68c685f9a876e3264c3da2902a8 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sun, 17 Jan 2021 20:21:24 +0100 Subject: [PATCH] feat: Reliably sort table rows, total count split into footer --- dashboard_template.xhtml | 15 +++++++++++++++ plot.py | 22 +++++++++++++++------- site/rki-dashboard.css | 10 ++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/dashboard_template.xhtml b/dashboard_template.xhtml index d506e49..a25f592 100644 --- a/dashboard_template.xhtml +++ b/dashboard_template.xhtml @@ -80,6 +80,21 @@ {% endfor %} + + + Gesamt + {{ details_total.total_vaccinations }} + {{ details_total.total_vaccinations_percentage }} % + {{ details_total.vaccination_reason_age }} + {{ details_total.vaccination_reason_age_percentage }} % + {{ details_total.vaccination_reason_job }} + {{ details_total.vaccination_reason_job_percentage }} % + {{ details_total.vaccination_reason_medical }} + {{ details_total.vaccination_reason_medical_percentage }} % + {{ details_total.vaccination_reason_oldhome }} + {{ details_total.vaccination_reason_oldhome_percentage }} % + +
Tabelle 1: diff --git a/plot.py b/plot.py index 14212f9..7e43da0 100644 --- a/plot.py +++ b/plot.py @@ -128,9 +128,9 @@ vaccination_reason_oldhome_by_land = details_sheet['Pflegeheim-bewohnerIn*'].ilo details_per_land = {} details_per_land_formatted = {} -for i in range(len(land_names)): - details_per_land[land_names[i]] = { +def row_to_details(i): + return { 'total_vaccinations': int(total_vaccinations_by_land[i]), 'total_vaccinations_percentage': vaccination_per_mille_by_land[i] / 10, 'vaccination_reason_age': int(vaccination_reason_age_by_land[i]), @@ -141,9 +141,10 @@ for i in range(len(land_names)): 'vaccination_reason_medical_percentage': np.round(vaccination_reason_medical_by_land[i] / total_vaccinations_by_land[i] * 100), 'vaccination_reason_oldhome': int(vaccination_reason_oldhome_by_land[i]), 'vaccination_reason_oldhome_percentage': np.round(vaccination_reason_oldhome_by_land[i] / total_vaccinations_by_land[i] * 100), - } - details_per_land_formatted[land_names[i]] = { + +def row_to_details_formatted(i): + return { 'total_vaccinations': '{:n}'.format(int(total_vaccinations_by_land[i])).replace('.', ' '), 'total_vaccinations_percentage': '{:.3n}'.format(np.round(vaccination_per_mille_by_land[i] / 10, 2)), 'vaccination_reason_age': '{:n}'.format(int(vaccination_reason_age_by_land[i])).replace('.', ' '), @@ -153,11 +154,17 @@ for i in range(len(land_names)): 'vaccination_reason_medical': '{:n}'.format(int(vaccination_reason_medical_by_land[i])).replace('.', ' '), 'vaccination_reason_medical_percentage': '{:n}'.format(np.round(vaccination_reason_medical_by_land[i] / total_vaccinations_by_land[i] * 100)), 'vaccination_reason_oldhome': '{:n}'.format(int(vaccination_reason_oldhome_by_land[i])).replace('.', ' '), - 'vaccination_reason_oldhome_percentage': '{:n}'.format(np.round(vaccination_reason_oldhome_by_land[i] / total_vaccinations_by_land[i] * 100)), - + 'vaccination_reason_oldhome_percentage': '{:n}'.format(np.round(vaccination_reason_oldhome_by_land[i] / total_vaccinations_by_land[i] * 100)) } +for i in range(len(land_names) - 1): + + details_per_land[land_names[i]] = row_to_details(i) + details_per_land_formatted[land_names[i]] = row_to_details_formatted(i) + +details_total = row_to_details(16) +details_total_formatted = row_to_details_formatted(16) archive_folder = site_folder + 'archive/' + filename_stand @@ -274,7 +281,8 @@ def render_dashboard(): mean_vaccinations_last_seven_days = '{:n}'.format(mean_vaccinations_last_seven_days_int).replace('.', ' '), mean_vaccinations_last_seven_days_herd_immunity = mean_vaccinations_last_seven_days_herd_immunity.strftime(df), mean_vaccinations_last_seven_days_done = mean_vaccinations_last_seven_days_done.strftime(df), - details_per_land = details_per_land_formatted + details_per_land = dict(sorted(details_per_land_formatted.items(), key=lambda item: item[0])), + details_total = details_total_formatted ).dump('site/index.xhtml') shutil.copyfile(dashboard_filename, dashboard_archive_filename) diff --git a/site/rki-dashboard.css b/site/rki-dashboard.css index 52cd444..5167dfb 100644 --- a/site/rki-dashboard.css +++ b/site/rki-dashboard.css @@ -68,6 +68,7 @@ figure { table { border-collapse: collapse; + background: white; } table td, table th { @@ -86,3 +87,12 @@ table tbody th { table td.number { text-align: right; } + +thead { + border-bottom: 2px solid #333333; +} + +tfoot { + background: white; + border-top: 2px solid #333333; +}