misc(aurora): improved Change.from_dict()
This commit is contained in:
parent
64758686bb
commit
a3ad38f338
1 changed files with 4 additions and 4 deletions
|
@ -40,16 +40,16 @@ class Change(AuroraBaseModel):
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
if data.get('duration'):
|
if data.get('duration'):
|
||||||
logger.debug(f"Duration: {data['duration']}")
|
logger.debug(f"Duration: {data['duration']}")
|
||||||
if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL":
|
if data.get('duration') and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL":
|
||||||
duration = timedelta_from_string(data["duration"])
|
duration = timedelta_from_string(data["duration"])
|
||||||
elif "duration" in data and isinstance(data["duration"], timedelta):
|
elif data.get('duration') and isinstance(data["duration"], timedelta):
|
||||||
duration = data["duration"]
|
duration = data["duration"]
|
||||||
else:
|
else:
|
||||||
duration = None
|
duration = None
|
||||||
|
|
||||||
if "end_timestamp" in data and data["end_timestamp"] and not isinstance(data["end_timestamp"], datetime):
|
if data.get('end_timestamp') and not isinstance(data["end_timestamp"], datetime):
|
||||||
end_timestamp = datetime.fromtimestamp(data["end_timestamp"])
|
end_timestamp = datetime.fromtimestamp(data["end_timestamp"])
|
||||||
elif "end_timestamp" in data and isinstance(data["end_timestamp"], datetime):
|
elif data.get('end_timestamp') and isinstance(data["end_timestamp"], datetime):
|
||||||
end_timestamp = data["end_timestamp"]
|
end_timestamp = data["end_timestamp"]
|
||||||
else:
|
else:
|
||||||
end_timestamp = None
|
end_timestamp = None
|
||||||
|
|
Loading…
Reference in a new issue