mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-16 02:51:56 +00:00
merge: reconcile isolated measurement PR package with integration
# Conflicts: # docs/_generated/openapi.md # openapi.json # src/akkudoktoreos/measurement/measurement.py # tests/test_battery_capacity.py
This commit is contained in:
@@ -580,13 +580,17 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence[MeasurementDataR
|
||||
if not measurement_file_path.exists():
|
||||
return False
|
||||
try:
|
||||
# Measurement is a singleton: validating a temporary Measurement
|
||||
# returns the existing instance and discards serialized records.
|
||||
# Measurement is a singleton; validating another Measurement
|
||||
# returns this instance instead of restoring serialized records.
|
||||
payload = json.loads(measurement_file_path.read_text(encoding="utf-8"))
|
||||
records = [MeasurementDataRecord.model_validate(data)
|
||||
for data in payload.get("records", [])]
|
||||
# Validate the complete file before modifying the live records.
|
||||
records = [
|
||||
MeasurementDataRecord.model_validate(data)
|
||||
for data in payload.get("records", [])
|
||||
]
|
||||
for record in records:
|
||||
await self.insert_by_datetime(record)
|
||||
except Exception as e:
|
||||
logger.exception("Cannot load measurements")
|
||||
return False
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user