fix(v2-ingestion): harden LBA/BCL snapshot contract for public data
This commit is contained in:
@ -16,6 +16,28 @@ def _first_non_empty(record: dict[str, Any], *keys: str) -> Any:
|
||||
return None
|
||||
|
||||
|
||||
ESSENTIAL_FIELDS = {
|
||||
"competition_external_id",
|
||||
"competition_name",
|
||||
"season",
|
||||
"team_external_id",
|
||||
"team_name",
|
||||
"player_external_id",
|
||||
"full_name",
|
||||
"games_played",
|
||||
"minutes_per_game",
|
||||
"points_per_game",
|
||||
"rebounds_per_game",
|
||||
"assists_per_game",
|
||||
"steals_per_game",
|
||||
"blocks_per_game",
|
||||
"turnovers_per_game",
|
||||
"fg_pct",
|
||||
"three_pt_pct",
|
||||
"ft_pct",
|
||||
}
|
||||
|
||||
|
||||
class BCLSnapshotExtractor(BaseSnapshotExtractor):
|
||||
"""
|
||||
Basketball Champions League MVP extractor.
|
||||
@ -122,7 +144,7 @@ class BCLSnapshotExtractor(BaseSnapshotExtractor):
|
||||
"ft_pct": _first_non_empty(source_record, "ft_pct", "ft_percentage"),
|
||||
}
|
||||
|
||||
missing = [key for key, value in normalized.items() if key != "role" and value in (None, "")]
|
||||
missing = [key for key in ESSENTIAL_FIELDS if normalized.get(key) in (None, "")]
|
||||
if missing:
|
||||
raise ExtractorNormalizationError(f"bcl row missing required fields: {', '.join(sorted(missing))}")
|
||||
|
||||
|
||||
@ -16,6 +16,28 @@ def _first_non_empty(record: dict[str, Any], *keys: str) -> Any:
|
||||
return None
|
||||
|
||||
|
||||
ESSENTIAL_FIELDS = {
|
||||
"competition_external_id",
|
||||
"competition_name",
|
||||
"season",
|
||||
"team_external_id",
|
||||
"team_name",
|
||||
"player_external_id",
|
||||
"full_name",
|
||||
"games_played",
|
||||
"minutes_per_game",
|
||||
"points_per_game",
|
||||
"rebounds_per_game",
|
||||
"assists_per_game",
|
||||
"steals_per_game",
|
||||
"blocks_per_game",
|
||||
"turnovers_per_game",
|
||||
"fg_pct",
|
||||
"three_pt_pct",
|
||||
"ft_pct",
|
||||
}
|
||||
|
||||
|
||||
class LBASnapshotExtractor(BaseSnapshotExtractor):
|
||||
"""
|
||||
LBA (Lega Basket Serie A) MVP extractor.
|
||||
@ -122,7 +144,7 @@ class LBASnapshotExtractor(BaseSnapshotExtractor):
|
||||
"ft_pct": _first_non_empty(source_record, "ft_pct", "ft_percentage"),
|
||||
}
|
||||
|
||||
missing = [key for key, value in normalized.items() if key != "role" and value in (None, "")]
|
||||
missing = [key for key in ESSENTIAL_FIELDS if normalized.get(key) in (None, "")]
|
||||
if missing:
|
||||
raise ExtractorNormalizationError(f"lba row missing required fields: {', '.join(sorted(missing))}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user