diff --git a/app/parsers/helpers.py b/app/parsers/helpers.py index f5de47be..1ff7e88e 100644 --- a/app/parsers/helpers.py +++ b/app/parsers/helpers.py @@ -32,8 +32,8 @@ def get_computed_stat_value(input_str: str) -> str | float | int: return int(input_str.replace("%", "").replace(",", "")) # Float format - if re.match(r"^-?\d+\.\d+$", input_str): - return float(input_str) + if re.match(r"^-?\d+(,\d+)*\.\d+$", input_str): + return float(input_str.replace(",", "")) # Return 0 value if : # - Zero time fought with a character ("--") diff --git a/pyproject.toml b/pyproject.toml index 6a09b356..50ecc7aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "overfast-api" -version = "2.33.0" +version = "2.33.1" description = "Overwatch API giving data about heroes, maps, and players statistics." license = "MIT" authors = ["Valentin PORCHET "] diff --git a/tests/parsers/test_helpers.py b/tests/parsers/test_helpers.py index b7d676ab..159e37c4 100644 --- a/tests/parsers/test_helpers.py +++ b/tests/parsers/test_helpers.py @@ -9,10 +9,10 @@ ("input_str", "result"), [ # Time format in hour:min:sec => seconds - ("1,448:50:56", 5215856), - ("205:08:38", 738518), - ("12:03:52", 43432), - ("5:42:42", 20562), + ("1,448:50:56", 5_215_856), + ("205:08:38", 738_518), + ("12:03:52", 43_432), + ("5:42:42", 20_562), ("-0:00:00", 0), # Time format in min:sec => seconds ("11:40", 700), @@ -26,12 +26,13 @@ ("-86", -86), ("46%", 46), ("208", 208), - ("12,585", 12585), - ("68,236,356", 68236356), + ("12,585", 12_585), + ("68,236,356", 68_236_356), # Float format ("7.58", 7.58), ("37.89", 37.89), ("-86.96", -86.96), + ("1,102.5", 1_102.5), # Zero time fought with a character ("--", 0), # Invalid value (not a number)