fix: apply break-even threshold on player stat profile (2.5.2)
build_leaderboard, player_session_series, and session_breakdown_series in the player detail and players routes were all called without league.break_even_cents, so win/loss/even classification always used the $1.00 default regardless of per-league settings.
This commit is contained in:
1 parent
882726e5e9
commit
51bb8f03f6
3 files changed
+11
-11
No files matched your search
@@ -31,8 +31,8 @@ def color_for_name(name: str, names: list[str]) -> str:
|
||||
return PLAYER_PALETTE[index % len(PLAYER_PALETTE)]
|
||||
|
||||
|
||||
def net_tone(value_cents: int) -> str:
|
||||
bucket = net_result_bucket(value_cents)
|
||||
def net_tone(value_cents: int, break_even_cents: int = 100) -> str:
|
||||
bucket = net_result_bucket(value_cents, break_even_cents)
|
||||
|
||||
if bucket == "win":
|
||||
return "#6fc093" # --pos
|
||||
@@ -96,7 +96,7 @@ def cumulative_profit_series(sessions: list[SessionSummary]) -> dict[str, object
|
||||
|
||||
|
||||
def player_session_series(
|
||||
sessions: list[SessionSummary], player_name: str
|
||||
sessions: list[SessionSummary], player_name: str, break_even_cents: int = 100
|
||||
) -> dict[str, Any]:
|
||||
ordered_sessions = sorted(sessions, key=session_sort_key)
|
||||
labels: list[str] = []
|
||||
@@ -130,12 +130,12 @@ def player_session_series(
|
||||
"labels": labels,
|
||||
"color": color_for_name(player_name, all_player_names),
|
||||
"net_values": net_values,
|
||||
"net_colors": [net_tone(round(value * 100)) for value in net_values],
|
||||
"net_colors": [net_tone(round(value * 100), break_even_cents) for value in net_values],
|
||||
"cumulative_values": cumulative_values,
|
||||
}
|
||||
|
||||
|
||||
def session_breakdown_series(session: SessionSummary) -> dict[str, Any]:
|
||||
def session_breakdown_series(session: SessionSummary, break_even_cents: int = 100) -> dict[str, Any]:
|
||||
ordered_entries = sorted(
|
||||
session.entries,
|
||||
key=lambda entry: (entry.net_cents, entry.player_name.casefold()),
|
||||
@@ -145,5 +145,5 @@ def session_breakdown_series(session: SessionSummary) -> dict[str, Any]:
|
||||
return {
|
||||
"labels": [entry.player_name for entry in ordered_entries],
|
||||
"net_values": [round(entry.net_cents / 100, 2) for entry in ordered_entries],
|
||||
"net_colors": [net_tone(entry.net_cents) for entry in ordered_entries],
|
||||
"net_colors": [net_tone(entry.net_cents, break_even_cents) for entry in ordered_entries],
|
||||
}
|
||||
Reference in new issue
Block a user