2.0.0-rc2: Achievements Refactored & Admin improved.

This commit is contained in:
2026-08-09 01:34:20 +08:00
parent 3874bf57a9
commit 63a0751aba
29 changed files with 2143 additions and 355 deletions
+57
View File
@@ -246,6 +246,7 @@ class IntegrityService:
@staticmethod
def _check_l3(db, roster_ids, checks, counts):
required_tables = {
'dm_discovery_insights',
'dm_duo_stats',
'dm_match_player_reports',
'dm_match_reports',
@@ -257,6 +258,7 @@ class IntegrityService:
'dm_player_record_events',
'dm_player_records',
'dm_player_weapon_stats',
'dm_performance_medals',
'dm_lineup_stats',
'dm_team_season_stats',
}
@@ -309,6 +311,12 @@ class IntegrityService:
counts['l3_awards'] = db.execute(
'SELECT COUNT(*) FROM dm_player_awards'
).fetchone()[0]
counts['l3_discoveries'] = db.execute(
'SELECT COUNT(*) FROM dm_discovery_insights'
).fetchone()[0]
counts['l3_medals'] = db.execute(
'SELECT COUNT(*) FROM dm_performance_medals'
).fetchone()[0]
expected_matches = counts.get('matches', 0)
IntegrityService._check(
checks,
@@ -443,6 +451,8 @@ class IntegrityService:
('l3_record_events', 'Record event mart'),
('l3_seasons', 'Team season mart'),
('l3_awards', 'Player award mart'),
('l3_discoveries', 'Discovery insight mart'),
('l3_medals', 'Map and ELO medal mart'),
):
value = counts[key]
IntegrityService._check(
@@ -453,6 +463,53 @@ class IntegrityService:
value,
)
discovery_tones = {
row[0] for row in db.execute(
'SELECT DISTINCT tone FROM dm_discovery_insights'
)
}
IntegrityService._check(
checks,
'Discovery tone coverage',
(
'pass'
if discovery_tones == {'positive', 'negative', 'fun'}
else 'fail'
),
f"tones: {', '.join(sorted(discovery_tones))}",
len(discovery_tones),
)
invalid_medals = db.execute(
"""
SELECT COUNT(*)
FROM dm_performance_medals
WHERE matches < 5
OR medal_rank NOT BETWEEN 1 AND 3
"""
).fetchone()[0]
duplicate_medals = db.execute(
"""
SELECT COUNT(*)
FROM (
SELECT dimension_type, dimension_key, medal_rank, COUNT(*) AS n
FROM dm_performance_medals
GROUP BY dimension_type, dimension_key, medal_rank
HAVING n > 1
)
"""
).fetchone()[0]
IntegrityService._check(
checks,
'Performance medal validity',
'pass' if invalid_medals == 0 and duplicate_medals == 0 else 'fail',
(
f'{invalid_medals} invalid samples, '
f'{duplicate_medals} duplicate ranks'
),
invalid_medals + duplicate_medals,
)
if roster_ids:
placeholders = ','.join('?' for _ in roster_ids)
scope_sql = f"AND steam_id_64 IN ({placeholders})"