Skip to content

Commit

Permalink
More float conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Oct 2, 2024
1 parent 95339fe commit 54a5252
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ def log_to_influxdb(
"""
print(f'Tags: {tags}, Fields: {fields}')

def _force_float(field_name: str) -> None:
if field_name in fields:
fields[field_name] = float(fields[field_name])

# Force data type for certain fields
if 'bit_rate_download' in fields:
fields['bit_rate_download'] = float(fields['bit_rate_download'])
if 'bit_rate_upload' in fields:
fields['bit_rate_upload'] = float(fields['bit_rate_upload'])
_force_float('bit_rate_download')
_force_float('bit_rate_upload')
_force_float('octo_send_bitrate')
_force_float('octo_receive_bitrate')

json_body = [{
'measurement': 'jvb_stats',
Expand Down

0 comments on commit 54a5252

Please sign in to comment.