Skip to content

Commit

Permalink
fix zone_rankings giving up on exception (#1)
Browse files Browse the repository at this point in the history
* fix zone_rankings giving up on exception

* todo note on character zone rankings fix

---------

Co-authored-by: Markus Wang Halvorsen <[email protected]>
  • Loading branch information
AHuynh and halworsen authored Feb 13, 2024
1 parent fe50f06 commit b428f99
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions fflogsapi/characters/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,29 @@ def zone_rankings(
jobs = self._client.jobs()
encounters = []
for rank in result['rankings']:
from ..world.encounter import FFLogsEncounter
encounter = FFLogsEncounter(id=rank['encounter']['id'], client=self._client)
job = list(filter(lambda j: j.slug == rank['spec'], jobs))[0]
best_job = list(filter(lambda j: j.slug == rank['bestSpec'], jobs))[0]

encounters.append(FFLogsZoneEncounterRanking(
locked_in=rank['lockedIn'],
encounter=encounter,
rank_percent=rank['rankPercent'],
median_percent=rank['medianPercent'],
best_amount=rank['bestAmount'],
fastest_kill=rank['fastestKill'],
kills=rank['totalKills'],
job=job,
best_job=best_job,
all_stars=self._make_all_stars_ranking(rank['allStars'], zone=zone, job=job),
))
# TODO: real fixes instead of ignoring the issue
# IndexError is from the spec filters on null rankings
# StopIteration is from the allstars ranking construction
try:
from ..world.encounter import FFLogsEncounter
encounter = FFLogsEncounter(id=rank['encounter']['id'], client=self._client)
job = list(filter(lambda j: j.slug == rank['spec'], jobs))[0]
best_job = list(filter(lambda j: j.slug == rank['bestSpec'], jobs))[0]

encounters.append(FFLogsZoneEncounterRanking(
locked_in=rank['lockedIn'],
encounter=encounter,
rank_percent=rank['rankPercent'],
median_percent=rank['medianPercent'],
best_amount=rank['bestAmount'],
fastest_kill=rank['fastestKill'],
kills=rank['totalKills'],
job=job,
best_job=best_job,
all_stars=self._make_all_stars_ranking(rank['allStars'], zone=zone, job=job),
))
except (IndexError, StopIteration):
continue

return FFLogsZoneRanking(
zone=zone,
Expand Down

0 comments on commit b428f99

Please sign in to comment.