fix: use entity_to_row for backup CSV output and handle non-numeric state values

Switch backup to write converted entities instead of raw table rows via
entity_to_row, and map string state values like "Payed"/"Recived" to their
integer equivalents during CSV parsing. Add sandbox.toml config.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 20:53:55 +08:00
parent c5897e5d0d
commit ef449729d7
3 changed files with 22 additions and 4 deletions

View File

@@ -43,8 +43,14 @@ def parse_row(raw: dict[str, str]) -> dict[str, Any]:
result[col] = datetime.fromisoformat(val)
elif col in ("revenue", "prodPrice"):
result[col] = float(val)
elif col in ("prodCount", "state", "ver"):
elif col in ("prodCount", "ver"):
result[col] = int(val)
elif col == "state":
try:
result[col] = int(val)
except ValueError:
_STATE_MAP = {"Payed": 0, "Recived": 1}
result[col] = _STATE_MAP.get(val, val)
else:
result[col] = val
return result