Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
uberfastman committed Sep 29, 2024
2 parents af6b84d + 9343504 commit dbfb292
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions report/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def create_pdf_report(self) -> Path:

season_avg_points_by_position = defaultdict(list)
season_weekly_top_scorers = []
season_weekly_low_scorers = []
season_weekly_highest_ce = []
season_weekly_teams_results = []

Expand Down Expand Up @@ -232,6 +233,14 @@ def create_pdf_report(self) -> Path:
}
season_weekly_top_scorers.append(top_scorer)

low_scorer = {
"week": week_counter,
"team": report_data.data_for_scores[-1][1],
"manager": report_data.data_for_scores[-1][2],
"score": report_data.data_for_scores[-1][3],
}
season_weekly_low_scorers.append(low_scorer)

highest_ce = {
"week": week_counter,
"team": report_data.data_for_coaching_efficiency[0][1],
Expand Down Expand Up @@ -297,6 +306,7 @@ def create_pdf_report(self) -> Path:

report_data.data_for_season_avg_points_by_position = season_avg_points_by_position
report_data.data_for_season_weekly_top_scorers = season_weekly_top_scorers
report_data.data_for_season_weekly_low_scorers = season_weekly_low_scorers
report_data.data_for_season_weekly_highest_ce = season_weekly_highest_ce

# calculate season average metrics and then add columns for them to their respective metric table data
Expand Down
1 change: 1 addition & 0 deletions report/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(self, league: BaseLeague, season_weekly_teams_results, week_counter
# create attributes for later updating
self.data_for_season_avg_points_by_position = None
self.data_for_season_weekly_top_scorers = None
self.data_for_season_weekly_low_scorers = None
self.data_for_season_weekly_highest_ce = None

# current standings data
Expand Down
36 changes: 36 additions & 0 deletions report/pdf/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def __init__(self, season: int, league: BaseLeague, playoff_prob_sims: int,
self.bad_boy_headers = [["Place", "Team", "Manager", "Bad Boy Pts", "Worst Offense", "# Offenders"]]
self.beef_headers = [["Place", "Team", "Manager", "TABBU(s)"]]
self.weekly_top_scorer_headers = [["Week", "Team", "Manager", "Score"]]
self.weekly_low_scorer_headers = [["Week", "Team", "Manager", "Score"]]
self.weekly_highest_ce_headers = [["Week", "Team", "Manager", "Coaching Efficiency (%)"]]
self.tie_for_first_footer = "<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*Tie(s).</i>"

Expand Down Expand Up @@ -508,6 +509,7 @@ def __init__(self, season: int, league: BaseLeague, playoff_prob_sims: int,
self.data_for_weekly_points_by_position = report_data.data_for_weekly_points_by_position
self.data_for_season_average_team_points_by_position = report_data.data_for_season_avg_points_by_position
self.data_for_season_weekly_top_scorers = report_data.data_for_season_weekly_top_scorers
self.data_for_season_weekly_low_scorers = report_data.data_for_season_weekly_low_scorers
self.data_for_season_weekly_highest_ce = report_data.data_for_season_weekly_highest_ce

# dynamically create table styles based on number of ties in metrics
Expand Down Expand Up @@ -713,6 +715,18 @@ def create_section(self, title_text: str, headers: List[List[str]], data: Any,
temp_data.append(entry)
data = temp_data

if metric_type == "low_scorers":
temp_data = []
for wk in data:
entry = [
wk["week"],
wk["team"],
wk["manager"],
wk["score"]
]
temp_data.append(entry)
data = temp_data

if metric_type == "highest_ce":
temp_data = []
for wk in data:
Expand Down Expand Up @@ -1622,6 +1636,26 @@ def generate_pdf(self, filename_with_path: Path, line_chart_data_list: List[List
))
elements.append(self.spacer_twentieth_inch)

if settings.report_settings.league_weekly_low_scorers_bool:
weekly_low_scorers_title_str = "Weekly Low Scorers"
weekly_low_scorers_page_title = self.create_title(
"<i>" + weekly_low_scorers_title_str + "</i>", element_type="chart",
anchor="<a name = page.html#" + str(self.toc.get_current_anchor()) + "></a>")
elements.append(weekly_low_scorers_page_title)

# weekly low scorers
elements.append(self.create_section(
"Weekly Low Scorers",
self.weekly_top_scorer_headers,
self.data_for_season_weekly_low_scorers,
self.style_no_highlight,
self.style_no_highlight,
self.widths_04_cols_no_1,
metric_type="top_scorers",
section_title_function=self.toc.add_top_performers_section
))
elements.append(self.spacer_twentieth_inch)

if settings.report_settings.league_weekly_highest_ce_bool:
weekly_highest_ce_title_str = "Weekly Highest Coaching Efficiency"
weekly_highest_ce_page_title = self.create_title(
Expand All @@ -1642,6 +1676,7 @@ def generate_pdf(self, filename_with_path: Path, line_chart_data_list: List[List
))

if (settings.report_settings.league_weekly_top_scorers_bool
or settings.report_settings.league_weekly_low_scorers_bool
or settings.report_settings.league_weekly_highest_ce_bool):
elements.append(self.add_page_break())

Expand Down Expand Up @@ -1763,6 +1798,7 @@ def __init__(self, font, font_size, break_ties):
]

if (settings.report_settings.league_weekly_top_scorers_bool
or settings.report_settings.league_weekly_low_scorers_bool
or settings.report_settings.league_weekly_highest_ce_bool):
self.toc_top_performers_section_data = [
[Paragraph("<b><i>Top Performers</i></b>", self.toc_style_title_right),
Expand Down
2 changes: 2 additions & 0 deletions resources/documentation/descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@

weekly_top_scorers = "Running list of each week's highest scoring team. Can be used for weekly highest points payouts."

weekly_low_scorers = "Running list of each week's lowest scoring team."

weekly_highest_coaching_efficiency = "Running list of each week's team with the highest coaching efficiency. Can be " \
"used for weekly highest coaching efficiency payouts."
1 change: 1 addition & 0 deletions utilities/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class ReportSettings(CustomSettings):
league_bad_boy_rankings_bool: bool = Field(True, title=__qualname__)
league_beef_rankings_bool: bool = Field(True, title=__qualname__)
league_weekly_top_scorers_bool: bool = Field(True, title=__qualname__)
league_weekly_low_scorers_bool: bool = Field(True, title=__qualname__)
league_weekly_highest_ce_bool: bool = Field(True, title=__qualname__)
report_time_series_charts_bool: bool = Field(True, title=__qualname__)
report_team_stats_bool: bool = Field(True, title=__qualname__)
Expand Down

0 comments on commit dbfb292

Please sign in to comment.