Skip to content

Commit

Permalink
fix: fixed unsupported big float values
Browse files Browse the repository at this point in the history
  • Loading branch information
TeKrop committed Aug 2, 2024
1 parent 40d067a commit 9bcb0b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ("--")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
13 changes: 7 additions & 6 deletions tests/parsers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down

0 comments on commit 9bcb0b3

Please sign in to comment.