Skip to content

Commit

Permalink
fixed issue at start-up with search data retrieval (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeKrop authored Dec 15, 2024
1 parent 62c77bd commit f21bbf0
Show file tree
Hide file tree
Showing 55 changed files with 237 additions and 202 deletions.
18 changes: 12 additions & 6 deletions app/players/commands/update_search_data_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ def transform_search_data(
search_data: dict, data_type: SearchDataType
) -> dict[str, str]:
def get_data_type_value(data_value: dict) -> str:
match data_type:
case SearchDataType.PORTRAIT | SearchDataType.NAMECARD:
return data_value["icon"]

case SearchDataType.TITLE:
return data_value["name"]["en_US"]
try:
match data_type:
case SearchDataType.PORTRAIT | SearchDataType.NAMECARD:
return data_value["icon"]

case SearchDataType.TITLE:
return data_value["name"]
except (KeyError, TypeError):
error_message = f"Empty value for {data_type} in search data"
logger.exception(error_message)
send_discord_webhook_message(error_message)
return ""

return {
data_key: get_data_type_value(data_value)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "overfast-api"
version = "3.8.0"
version = "3.8.1"
description = "Overwatch API giving data about heroes, maps, and players statistics."
license = {file = "LICENSE"}
authors = [
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/ana.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/ashe.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/baptiste.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/bastion.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/brigitte.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/cassidy.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes/doomfist.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/dva.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/echo.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/genji.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/hanzo.html

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions tests/fixtures/html/heroes/hazard.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/illari.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/junker-queen.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/junkrat.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/juno.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/kiriko.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/lifeweaver.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/lucio.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/mauga.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/mei.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/mercy.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/moira.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/orisa.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/pharah.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/ramattra.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/reaper.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/reinhardt.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/roadhog.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes/sigma.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/sojourn.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/soldier-76.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/sombra.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/symmetra.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/torbjorn.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/tracer.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/venture.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/widowmaker.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes/winston.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes/wrecking-ball.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/html/heroes/zarya.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/heroes/zenyatta.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/home.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/players/JohnV1-1190.html

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions tests/fixtures/html/players/KIRIKO-12460.html

Large diffs are not rendered by default.

35 changes: 0 additions & 35 deletions tests/fixtures/html/players/KIRIKO-21253.html

This file was deleted.

6 changes: 3 additions & 3 deletions tests/fixtures/html/players/TeKrop-2217.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/html/players/Unknown-1234.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions tests/fixtures/html/search.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions tests/fixtures/json/search_players_blizzard_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"url": "d67b87a1fe23caffbca9%7Ce071d6c2df64c91dc7ad8f0eb73d5d05"
},
{
"battleTag": "KIRIKO#21253",
"battleTag": "KIRIKO#12460",
"frame": "0x0250000000000918",
"isPublic": false,
"lastUpdated": 1676730323,
"namecard": "0x0000000000000000",
"portrait": "0x0250000000004D59",
"title": "0x0000000000000000",
"url": "d67b87a1fe23caffbca9%7Ce071d6c2df64c91dc7ad8f0eb73d5d05"
"isPublic": true,
"lastUpdated": 1734242338,
"namecard": "0x02500000000066FF",
"portrait": "0x0250000000007B7D",
"title": "0x0250000000006311",
"url": "d9779ea3985ed6fcbba421a0%7Cbc8b49f152a4ff7848f37d6df5ec5106"
},
{
"battleTag": "Player#1112937",
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read_json_file(filepath: str) -> dict | list | None:

# List of players used for testing
players_ids = [
"KIRIKO-21253", # Profile with rank on only two roles
"KIRIKO-12460", # Console player
"TeKrop-2217", # Classic profile
"JohnV1-1190", # Player without any title ingame
]
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f21bbf0

Please sign in to comment.