From b1d97ba3fbf94ed7faf2981484b1a0814e0f60b1 Mon Sep 17 00:00:00 2001 From: cdpeca Date: Tue, 15 Oct 2024 21:17:43 +0530 Subject: [PATCH] Calculated and added Season Total Rankings for Optimal Points section --- report/builder.py | 9 +++++++-- report/pdf/generator.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/report/builder.py b/report/builder.py index fdf8abb..6010b9b 100644 --- a/report/builder.py +++ b/report/builder.py @@ -329,10 +329,15 @@ def create_pdf_report(self) -> Path: team_luck_data_entry.append(team.weekly_overall_record.get_record_str()) # add season total optimal points to optimal points data + sorted_season_total_optimal_points_data = dict(sorted(season_total_optimal_points_data.items(), key=lambda x: x[1], reverse=True)) + list_sorted_season_total_optimal_points_data = [(i, k, v) for i, (k, v) in enumerate(sorted_season_total_optimal_points_data.items())] for team_optimal_points_data_entry in report_data.data_for_optimal_scores: - for team_name, season_total_optimal_points in season_total_optimal_points_data.items(): + for team_index, team_name, season_total_optimal_points in list_sorted_season_total_optimal_points_data: if team_optimal_points_data_entry[1] == team_name: - team_optimal_points_data_entry.append(f"{round(season_total_optimal_points, 2):.2f}") + place = team_index + 1 + total_optimal_points_ranked = str("{:.2f}".format(round(season_total_optimal_points, 2))) + " (" + str(place) +")" + team_optimal_points_data_entry.append(total_optimal_points_ranked) + report_data.data_for_power_rankings = season_average_calculator.get_average( time_series_power_rank_data, diff --git a/report/pdf/generator.py b/report/pdf/generator.py index e14ca4e..7994b37 100644 --- a/report/pdf/generator.py +++ b/report/pdf/generator.py @@ -435,7 +435,7 @@ def __init__(self, season: int, league: BaseLeague, playoff_prob_sims: int, self.scores_headers = [["Place", "Team", "Manager", "Points", "Season Avg. (Place)"]] self.efficiency_headers = [["Place", "Team", "Manager", "Coaching Efficiency (%)", "Season Avg. (Place)"]] self.luck_headers = [["Place", "Team", "Manager", "Luck", "Season Avg. (Place)", "Weekly Record (W-L)"]] - self.optimal_scores_headers = [["Place", "Team", "Manager", "Optimal Points", "Season Total"]] + self.optimal_scores_headers = [["Place", "Team", "Manager", "Optimal Points", "Season Total (Place)"]] self.bad_boy_headers = [["Place", "Team", "Manager", "Bad Boy Pts", "Worst Offense", "# Offenders"]] self.beef_headers = [["Place", "Team", "Manager", "TABBU(s)"]] self.high_roller_headers = [[