[locations] Shim fix for logdata for GeoLocs
This commit is contained in:
@ -635,6 +635,20 @@ class Scrobble(TimeStampedModel):
|
|||||||
if not log_dict:
|
if not log_dict:
|
||||||
log_dict = {}
|
log_dict = {}
|
||||||
|
|
||||||
|
# Special handling for GeoLocationLogData - data is nested under 'movement_detection'
|
||||||
|
# TODO there's a better way to fix this this at the LogData level
|
||||||
|
if logdata_cls.__name__ == "GeoLocationLogData":
|
||||||
|
instance_data = log_dict.get("movement_detection", {}).copy()
|
||||||
|
# Add top-level fields that GeoLocationLogData expects from BaseLogData/WithPeopleLogData
|
||||||
|
for field_name in ["description", "notes", "with_people_ids"]:
|
||||||
|
if field_name in log_dict:
|
||||||
|
instance_data[field_name] = log_dict[field_name]
|
||||||
|
try:
|
||||||
|
return logdata_cls(**instance_data)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Log data could not be loaded", e)
|
||||||
|
return logdata_cls()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return logdata_cls(**log_dict)
|
return logdata_cls(**log_dict)
|
||||||
except ParseError as e:
|
except ParseError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user