1.0.2-hotfix: Added matchlist new features.
This commit is contained in:
@@ -23,11 +23,66 @@ def detail(match_id):
|
||||
return "Match not found", 404
|
||||
|
||||
players = StatsService.get_match_players(match_id)
|
||||
# Convert sqlite3.Row objects to dicts to allow modification
|
||||
players = [dict(p) for p in players]
|
||||
|
||||
rounds = StatsService.get_match_rounds(match_id)
|
||||
|
||||
# Organize players by team
|
||||
team1_players = [p for p in players if p['team_id'] == 1]
|
||||
team2_players = [p for p in players if p['team_id'] == 2]
|
||||
# --- Roster Identification ---
|
||||
# Fetch active roster to identify "Our Team" players
|
||||
from web.services.web_service import WebService
|
||||
lineups = WebService.get_lineups()
|
||||
# Assume we use the first/active lineup
|
||||
active_roster_ids = []
|
||||
if lineups:
|
||||
try:
|
||||
active_roster_ids = json.loads(lineups[0]['player_ids_json'])
|
||||
except:
|
||||
pass
|
||||
|
||||
# Mark roster players (Ensure strict string comparison)
|
||||
roster_set = set(str(uid) for uid in active_roster_ids)
|
||||
for p in players:
|
||||
p['is_in_roster'] = str(p['steam_id_64']) in roster_set
|
||||
|
||||
# --- Party Size Calculation ---
|
||||
# Only calculate party size for OUR ROSTER members.
|
||||
# Group roster members by match_team_id
|
||||
roster_parties = {} # match_team_id -> count of roster members
|
||||
|
||||
for p in players:
|
||||
if p['is_in_roster']:
|
||||
mtid = p.get('match_team_id')
|
||||
if mtid and mtid > 0:
|
||||
key = f"tid_{mtid}"
|
||||
roster_parties[key] = roster_parties.get(key, 0) + 1
|
||||
|
||||
# Assign party size ONLY to roster members
|
||||
for p in players:
|
||||
if p['is_in_roster']:
|
||||
mtid = p.get('match_team_id')
|
||||
if mtid and mtid > 0:
|
||||
p['party_size'] = roster_parties.get(f"tid_{mtid}", 1)
|
||||
else:
|
||||
p['party_size'] = 1 # Solo roster player
|
||||
else:
|
||||
p['party_size'] = 0 # Hide party info for non-roster players
|
||||
|
||||
# Organize players by Side (team_id)
|
||||
# team_id 1 = Team 1, team_id 2 = Team 2
|
||||
# Note: group_id 1/2 usually corresponds to Team 1/2.
|
||||
# Fallback to team_id if group_id is missing or 0 (legacy data compatibility)
|
||||
team1_players = [p for p in players if p.get('group_id') == 1]
|
||||
team2_players = [p for p in players if p.get('group_id') == 2]
|
||||
|
||||
# If group_id didn't work (empty lists), try team_id grouping (if team_id is 1/2 only)
|
||||
if not team1_players and not team2_players:
|
||||
team1_players = [p for p in players if p['team_id'] == 1]
|
||||
team2_players = [p for p in players if p['team_id'] == 2]
|
||||
|
||||
# Explicitly sort by Rating DESC
|
||||
team1_players.sort(key=lambda x: x.get('rating', 0) or 0, reverse=True)
|
||||
team2_players.sort(key=lambda x: x.get('rating', 0) or 0, reverse=True)
|
||||
|
||||
return render_template('matches/detail.html', match=match,
|
||||
team1_players=team1_players, team2_players=team2_players,
|
||||
|
||||
Reference in New Issue
Block a user