Skip to content

Commit

Permalink
fix: refactored after review
Browse files Browse the repository at this point in the history
  • Loading branch information
TeKrop committed Nov 4, 2024
1 parent 375469f commit e97fa8b
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions app/players/parsers/player_career_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,29 @@ def _filter_all_stats_data(self, **kwargs) -> dict:
if not platform_filter and not gamemode_filter:
return stats_data

# Extract platform-specific data and update stats data
# to contain only platform-specific information
if platform_filter:
stats_data = {
platform_key: (
platform_data if platform_key == platform_filter else None
)
for platform_key, platform_data in stats_data.items()
}
filtered_data = {}

# Extract gamemode-specific data within the remaining platforms
# and update stats data to contain only gamemode-specific information
if gamemode_filter:
stats_data = {
platform_key: (
{
gamemode_key: (
gamemode_data if gamemode_key == gamemode_filter else None
)
for gamemode_key, gamemode_data in platform_data.items()
}
if platform_data is not None
else None
for platform_key, platform_data in stats_data.items():
if platform_filter and platform_key != platform_filter:
filtered_data[platform_key] = None
continue

if platform_data is None:
filtered_data[platform_key] = None
continue

if gamemode_filter is None:
filtered_data[platform_key] = platform_data
continue

filtered_data[platform_key] = {
gamemode_key: (
gamemode_data if gamemode_key == gamemode_filter else None
)
for platform_key, platform_data in stats_data.items()
for gamemode_key, gamemode_data in platform_data.items()
}

return stats_data
return filtered_data

def parse_data(self) -> dict:
# We must check if we have the expected section for profile. If not,
Expand Down

0 comments on commit e97fa8b

Please sign in to comment.