3.0.0 : Reconstructed Database System.
This commit is contained in:
@@ -40,7 +40,7 @@ def api_search():
|
||||
'steam_id': p_dict['steam_id_64'],
|
||||
'name': p_dict['username'],
|
||||
'avatar': p_dict['avatar_url'] or 'https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg',
|
||||
'rating': (f['basic_avg_rating'] if f else 0.0),
|
||||
'rating': (f['core_avg_rating'] if f else 0.0),
|
||||
'matches': matches_played
|
||||
})
|
||||
|
||||
@@ -163,63 +163,72 @@ def list_view():
|
||||
|
||||
@bp.route('/<int:lineup_id>')
|
||||
def detail(lineup_id):
|
||||
lineup = WebService.get_lineup(lineup_id)
|
||||
if not lineup:
|
||||
return "Lineup not found", 404
|
||||
|
||||
p_ids = json.loads(lineup['player_ids_json'])
|
||||
players = StatsService.get_players_by_ids(p_ids)
|
||||
|
||||
# Shared Matches
|
||||
shared_matches = StatsService.get_shared_matches(p_ids)
|
||||
|
||||
# Calculate Aggregate Stats
|
||||
agg_stats = {
|
||||
'avg_rating': 0,
|
||||
'avg_kd': 0,
|
||||
'avg_kast': 0
|
||||
}
|
||||
|
||||
radar_data = {
|
||||
'STA': 0, 'BAT': 0, 'HPS': 0, 'PTL': 0, 'SIDE': 0, 'UTIL': 0
|
||||
}
|
||||
|
||||
player_features = []
|
||||
|
||||
if players:
|
||||
count = len(players)
|
||||
total_rating = 0
|
||||
total_kd = 0
|
||||
total_kast = 0
|
||||
|
||||
# Radar totals
|
||||
r_totals = {k: 0 for k in radar_data}
|
||||
|
||||
for p in players:
|
||||
# Fetch L3 features for each player
|
||||
f = FeatureService.get_player_features(p['steam_id_64'])
|
||||
if f:
|
||||
player_features.append(f)
|
||||
total_rating += f['basic_avg_rating'] or 0
|
||||
total_kd += f['basic_avg_kd'] or 0
|
||||
total_kast += f['basic_avg_kast'] or 0
|
||||
|
||||
# Radar accumulation
|
||||
r_totals['STA'] += f['basic_avg_rating'] or 0
|
||||
r_totals['BAT'] += f['bat_avg_duel_win_rate'] or 0
|
||||
r_totals['HPS'] += f['hps_clutch_win_rate_1v1'] or 0
|
||||
r_totals['PTL'] += f['ptl_pistol_win_rate'] or 0
|
||||
r_totals['SIDE'] += f['side_rating_ct'] or 0
|
||||
r_totals['UTIL'] += f['util_usage_rate'] or 0
|
||||
else:
|
||||
player_features.append(None)
|
||||
|
||||
if count > 0:
|
||||
agg_stats['avg_rating'] = total_rating / count
|
||||
agg_stats['avg_kd'] = total_kd / count
|
||||
agg_stats['avg_kast'] = total_kast / count
|
||||
try:
|
||||
lineup = WebService.get_lineup(lineup_id)
|
||||
if not lineup:
|
||||
return "Lineup not found", 404
|
||||
|
||||
for k in radar_data:
|
||||
radar_data[k] = r_totals[k] / count
|
||||
p_ids = json.loads(lineup['player_ids_json'])
|
||||
players = StatsService.get_players_by_ids(p_ids)
|
||||
|
||||
# Shared Matches
|
||||
shared_matches = StatsService.get_shared_matches(p_ids)
|
||||
|
||||
# Calculate Aggregate Stats
|
||||
agg_stats = {
|
||||
'avg_rating': 0,
|
||||
'avg_kd': 0,
|
||||
'avg_kast': 0
|
||||
}
|
||||
|
||||
radar_data = {
|
||||
'STA': 0, 'BAT': 0, 'HPS': 0, 'PTL': 0, 'SIDE': 0, 'UTIL': 0
|
||||
}
|
||||
|
||||
player_features = []
|
||||
|
||||
if players:
|
||||
count = len(players)
|
||||
total_rating = 0
|
||||
total_kd = 0
|
||||
total_kast = 0
|
||||
|
||||
# Radar totals
|
||||
r_totals = {k: 0 for k in radar_data}
|
||||
|
||||
for p in players:
|
||||
# Fetch L3 features for each player
|
||||
f = FeatureService.get_player_features(p['steam_id_64'])
|
||||
if f:
|
||||
# Attach stats to player object for template
|
||||
p['rating'] = f.get('core_avg_rating') or 0
|
||||
p['stats'] = f
|
||||
|
||||
player_features.append(f)
|
||||
total_rating += f.get('core_avg_rating') or 0
|
||||
total_kd += f.get('core_avg_kd') or 0
|
||||
total_kast += f.get('core_avg_kast') or 0
|
||||
|
||||
# Radar accumulation (L3 Mapping)
|
||||
r_totals['STA'] += f.get('core_avg_rating') or 0 # Rating (Scale ~1.0)
|
||||
r_totals['BAT'] += (f.get('tac_opening_duel_winrate') or 0) * 2 # WinRate (0.5 -> 1.0) Scale to match Rating?
|
||||
r_totals['HPS'] += (f.get('tac_clutch_1v1_rate') or 0) * 2 # WinRate (0.5 -> 1.0)
|
||||
r_totals['PTL'] += ((f.get('score_pistol') or 0) / 50.0) # Score (0-100 -> 0-2.0)
|
||||
r_totals['SIDE'] += f.get('meta_side_ct_rating') or 0 # Rating (Scale ~1.0)
|
||||
r_totals['UTIL'] += f.get('tac_util_usage_rate') or 0 # Usage Rate (Count? or Rate?)
|
||||
else:
|
||||
player_features.append(None)
|
||||
p['rating'] = 0
|
||||
|
||||
if count > 0:
|
||||
agg_stats['avg_rating'] = total_rating / count
|
||||
agg_stats['avg_kd'] = total_kd / count
|
||||
agg_stats['avg_kast'] = total_kast / count
|
||||
|
||||
for k in radar_data:
|
||||
radar_data[k] = r_totals[k] / count
|
||||
|
||||
return render_template('teams/detail.html', lineup=lineup, players=players, agg_stats=agg_stats, shared_matches=shared_matches, radar_data=radar_data)
|
||||
return render_template('teams/detail.html', lineup=lineup, players=players, agg_stats=agg_stats, shared_matches=shared_matches, radar_data=radar_data)
|
||||
except Exception as e:
|
||||
import traceback
|
||||
return f"<pre>{traceback.format_exc()}</pre>", 500
|
||||
|
||||
Reference in New Issue
Block a user