Skip to content

Commit

Permalink
Add security check in handle_timeserie (#29)
Browse files Browse the repository at this point in the history
This is done to avoid crashing when the object has a timeserie attribute
without value.
  • Loading branch information
drscholly authored Feb 13, 2024
1 parent f19ead9 commit 148e449
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions toolbox/api/datagalaxy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ def handle_timeserie(property: dict) -> dict:
# Temporary solution: only copy the latest value of the TimeSerie
for key, value in property.items():
if isinstance(value, dict):
if 'lastEntry' in value:
if 'lastEntry' in value and value['lastEntry'] is not None:
# Expected format : "Date::Value"
property[key] = f"{value['lastEntry']['date']}::{value['lastEntry']['value']}"
last_entry = value['lastEntry']
if 'date' in last_entry and 'value' in last_entry:
property[key] = f"{last_entry['date']}::{last_entry['value']}"


def to_bulk_tree(properties: list) -> list:
Expand Down

0 comments on commit 148e449

Please sign in to comment.