test(v2-ingestion): harden public-source schema contract and docs
This commit is contained in:
@ -16,6 +16,16 @@ def _first_non_empty(record: dict[str, Any], *keys: str) -> Any:
|
||||
return None
|
||||
|
||||
|
||||
def _first_non_empty_text(record: dict[str, Any], *keys: str) -> str | None:
|
||||
for key in keys:
|
||||
value = record.get(key)
|
||||
if isinstance(value, str):
|
||||
stripped = value.strip()
|
||||
if stripped:
|
||||
return stripped
|
||||
return None
|
||||
|
||||
|
||||
ESSENTIAL_FIELDS = {
|
||||
"competition_external_id",
|
||||
"competition_name",
|
||||
@ -108,7 +118,9 @@ class BCLSnapshotExtractor(BaseSnapshotExtractor):
|
||||
team_external_id = _first_non_empty(source_record, "team_external_id", "team_id") or _first_non_empty(
|
||||
team_obj, "id", "team_id"
|
||||
)
|
||||
team_name = _first_non_empty(source_record, "team_name", "team") or _first_non_empty(team_obj, "name")
|
||||
team_name = _first_non_empty_text(source_record, "team_name", "team") or _first_non_empty_text(
|
||||
team_obj, "name"
|
||||
)
|
||||
|
||||
normalized = {
|
||||
"competition_external_id": self.competition_external_id,
|
||||
|
||||
Reference in New Issue
Block a user