Align balldontlie OpenAPI integration and clarify search metric semantics
This commit is contained in:
@ -20,6 +20,10 @@ from apps.players.models import Player
|
||||
from apps.stats.models import PlayerSeason
|
||||
|
||||
METRIC_SORT_KEYS = {"ppg_desc", "ppg_asc", "mpg_desc", "mpg_asc"}
|
||||
SEARCH_METRIC_SEMANTICS_TEXT = (
|
||||
"Search metrics are best eligible values per player (max per metric across eligible player-season rows). "
|
||||
"With season/team/competition/stat filters, eligibility is scoped by those filters."
|
||||
)
|
||||
|
||||
|
||||
def _years_ago_today(years: int) -> date:
|
||||
@ -213,6 +217,13 @@ def filter_players(queryset, data: dict):
|
||||
|
||||
|
||||
def annotate_player_metrics(queryset, data: dict | None = None):
|
||||
"""
|
||||
Annotate player list metrics using best-eligible semantics.
|
||||
|
||||
Each metric is computed as MAX over eligible player-season rows. This is intentionally
|
||||
not a single-row projection; different displayed metrics for one player can come from
|
||||
different eligible player-season rows.
|
||||
"""
|
||||
data = data or {}
|
||||
context_filter = _build_metric_context_filter(data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user