1.2.1 : Updated calculation

This commit is contained in:
2026-01-26 22:04:29 +08:00
parent ade29ec1e8
commit 1b9cab5628
6 changed files with 40 additions and 10 deletions

View File

@@ -101,18 +101,25 @@ def detail(steam_id):
# Ensure basic stats fallback if features missing or incomplete
basic = StatsService.get_player_basic_stats(steam_id)
from collections import defaultdict
if not features:
# Fallback to defaultdict with basic stats
features = defaultdict(lambda: None)
if basic:
features = {
features.update({
'basic_avg_rating': basic.get('rating', 0),
'basic_avg_kd': basic.get('kd', 0),
'basic_avg_kast': basic.get('kast', 0),
'basic_avg_adr': basic.get('adr', 0), # Pass ADR
}
'basic_avg_adr': basic.get('adr', 0),
})
else:
# Convert to defaultdict to handle missing keys gracefully (e.g. newly added columns)
# Use lambda: None so that Jinja can check 'if value is not none'
features = defaultdict(lambda: None, dict(features))
# If features exist but ADR is missing (not in L3), try to patch it from basic
if 'basic_avg_adr' not in features:
features = dict(features) # Convert to dict if row
if 'basic_avg_adr' not in features or features['basic_avg_adr'] is None:
features['basic_avg_adr'] = basic.get('adr', 0) if basic else 0
comments = WebService.get_comments('player', steam_id)