Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to allow for weekly low scorers to report #214

Merged
merged 9 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ For those of you who wish for the report to include a custom subset of the avail
LEAGUE_BAD_BOY_RANKINGS_BOOL=True
LEAGUE_BEEF_RANKINGS_BOOL=True
LEAGUE_WEEKLY_TOP_SCORERS_BOOL=True
LEAGUE_WEEKLY_LOW_SCORERS_BOOL=True
LEAGUE_WEEKLY_HIGHEST_CE_BOOL=True
REPORT_TIME_SERIES_CHARTS_BOOL=True
REPORT_TEAM_STATS_BOOL=True
Expand Down
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) -> str:

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) -> str:
}
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) -> str:

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
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 @@ -147,6 +147,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
Loading