Round DSP report values to whole numbers
This commit is contained in:
@@ -59,11 +59,15 @@ def read_response(response) -> str:
|
||||
return response.read().decode("utf-8", errors="replace")
|
||||
|
||||
|
||||
def to_number(value) -> float:
|
||||
def to_number(value) -> int:
|
||||
"""Return a nearest whole number for report metrics."""
|
||||
try:
|
||||
return float(value or 0)
|
||||
number = float(value or 0)
|
||||
except (TypeError, ValueError):
|
||||
return 0.0
|
||||
return 0
|
||||
# Metrics are non-negative in the source; this also handles any negative
|
||||
# values with conventional half-away-from-zero rounding.
|
||||
return int(number + 0.5) if number >= 0 else int(number - 0.5)
|
||||
|
||||
|
||||
def normalise_date(value) -> str:
|
||||
|
||||
Reference in New Issue
Block a user