Webhost: add total player location counts to tracker API (#5441)

This commit is contained in:
Etsuna
2025-09-24 20:08:14 +02:00
committed by GitHub
parent dc270303a9
commit 4525bae879
2 changed files with 28 additions and 1 deletions

View File

@@ -52,6 +52,12 @@ class PlayerStatus(TypedDict):
status: ClientStatus
class PlayerLocationsTotal(TypedDict):
team: int
player: int
total_locations: int
@api_endpoints.route("/tracker/<suuid:tracker>")
@cache.memoize(timeout=60)
def tracker_data(tracker: UUID) -> dict[str, Any]:
@@ -195,9 +201,16 @@ def static_tracker_data(tracker: UUID) -> dict[str, Any]:
})
break
player_locations_total: list[PlayerLocationsTotal] = []
for team, players in all_players.items():
for player in players:
player_locations_total.append(
{"team": team, "player": player, "total_locations": len(tracker_data.get_player_locations(player))})
return {
"groups": groups,
"datapackage": tracker_data._multidata["datapackage"],
"player_locations_total": player_locations_total,
}
# It should be exceedingly rare that slot data is needed, so it's separated out.