Skip to content

Commit

Permalink
fixed an issue with profiles containing invalid time values on Blizza…
Browse files Browse the repository at this point in the history
…rd pages (negative)
  • Loading branch information
Valentin committed Dec 9, 2022
1 parent ea9b376 commit 1e9cda8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions overfastapi/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# List of players used for testing
players_ids = [
"Dekk-2677", # Classic profile without rank
"KIRIKO-21253", # Profile with rank on only two roles
"Player-1112937", # Console player
"Player-137712", # Private profile
"SoSucre-2795", # Top player Open Queue
Expand Down
4 changes: 2 additions & 2 deletions overfastapi/parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_computed_stat_value(input_str: str) -> str | float | int:
"""

# Duration format in hour:min:sec => seconds
result = re.match(r"^([0-9]+[,]?[0-9]*?):([0-9]+):([0-9]+)$", input_str)
result = re.match(r"^([-]?[0-9]+[,]?[0-9]*?):([0-9]+):([0-9]+)$", input_str)
if result:
return (
int(result.group(1).replace(",", "")) * 3600
Expand All @@ -22,7 +22,7 @@ def get_computed_stat_value(input_str: str) -> str | float | int:
)

# Duration format in min:sec => seconds
result = re.match(r"^([0-9]+):([0-9]+)$", input_str)
result = re.match(r"^([-]?[0-9]+):([0-9]+)$", input_str)
if result:
return int(result.group(1)) * 60 + int(result.group(2))

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.3.0"
version = "2.3.1"
description = "Overwatch API giving data about heroes, maps, and players statistics."
authors = ["TeKrop <tekrop@gmail.com>"]
license = "MIT"
Expand Down
20 changes: 20 additions & 0 deletions tests/fixtures/html/players/KIRIKO-21253.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/fixtures/json/players/KIRIKO-21253.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/fixtures/json/players/Player-1112937.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/parsers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
("205:08:38", 738518),
("12:03:52", 43432),
("5:42:42", 20562),
("-0:00:00", 0),
# Time format in min:sec => seconds
("11:40", 700),
("04:10", 250),
("07:55", 475),
("00:11", 11),
("-00:00", 0),
# Int format
("0", 0),
("5", 5),
Expand Down

0 comments on commit 1e9cda8

Please sign in to comment.