Skip to content

Commit

Permalink
fix: fixed two issues with Blizzard profiles (#166)
Browse files Browse the repository at this point in the history
* fix: fixed two issues with Blizzard profiles

* bump version
  • Loading branch information
TeKrop authored Jul 27, 2024
1 parent e403d82 commit 6b68612
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ def get_computed_stat_value(input_str: str) -> str | float | int:
if re.match(r"^-?\d+\.\d+$", input_str):
return float(input_str)

# Zero time fought with a character if "--", else default value
return 0 if input_str == "--" else input_str
# Return 0 value if :
# - Zero time fought with a character ("--")
# - Invalid value in DOM ("NaN")
# Else default value
return 0 if input_str in {"--", "NaN"} else input_str


def get_division_from_icon(rank_url: str) -> CompetitiveDivision:
Expand Down
7 changes: 6 additions & 1 deletion app/parsers/player_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ def __get_heroes_comparisons(self, top_heroes_section: Tag) -> dict:
}

for category in CareerHeroesComparisonsCategory:
if category.value not in heroes_comparisons:
# Sometimes, Blizzard exposes the categories without any value
# In that case, we must assume we have no data at all
if (
category.value not in heroes_comparisons
or not heroes_comparisons[category.value]["values"]
):
heroes_comparisons[category.value] = None

return heroes_comparisons
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.32.0"
version = "2.32.1"
description = "Overwatch API giving data about heroes, maps, and players statistics."
license = "MIT"
authors = ["Valentin PORCHET <valentin.porchet@proton.me>"]
Expand Down
2 changes: 2 additions & 0 deletions tests/parsers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
("-86.96", -86.96),
# Zero time fought with a character
("--", 0),
# Invalid value (not a number)
("NaN", 0),
# Default value for anything else
("string", "string"),
],
Expand Down

0 comments on commit 6b68612

Please sign in to comment.