fix column matcher false-positive on shared table prefixes; round float durations for int columns

This commit is contained in:
Roberto Treviño Cervantes
2026-10-23 00:33:53 -06:00
parent c799e2ad90
commit 83c7c7f1d3
3 changed files with 30 additions and 3 deletions
+8
View File
@@ -31,6 +31,14 @@ def optional_str(v: Any) -> Any:
return text or None
def rounded_int(v: Any) -> Any:
"""A minutes/count field stored as an `int` column, whose source may
report a float (e.g. a duration measured to tenths of a minute)."""
if v is None or (isinstance(v, str) and v.strip() == ""):
return None
return round(float(v))
_DAY_FIRST_FORMATS = ("%d/%m/%Y", "%d-%m-%Y", "%d.%m.%Y", "%Y/%m/%d")
+6 -1
View File
@@ -17,7 +17,7 @@ from core.tea.enums import (
TipoGrafoelemento,
)
from webapi.imports.schemas.base import ImportSchema
from webapi.imports.schemas.coercion import edf_file, Catalog, CatalogValue, coerce_date, optional_str
from webapi.imports.schemas.coercion import edf_file, Catalog, CatalogValue, coerce_date, optional_str, rounded_int
_FUENTE_INTERPRETACION_EEG_CATALOG = Catalog(FuenteInterpretacionEeg)
_ESTADO_REGISTRO_EEG_CATALOG = Catalog(EstadoRegistroEeg)
@@ -84,6 +84,11 @@ class EegEstudioImportSchema(ImportSchema):
def _coerce_dates(cls, v):
return coerce_date(v)
@field_validator("eeg_duracion_min", mode="before")
@classmethod
def _coerce_duracion_min(cls, v):
return rounded_int(v)
@field_validator("eeg_estudio", mode="before")
@classmethod
def _valid_edf(cls, v):