3.0.0 : Reconstructed Database System.
This commit is contained in:
@@ -179,6 +179,7 @@ CREATE TABLE IF NOT EXISTS fact_match_players (
|
||||
rws REAL,
|
||||
mvp_count INTEGER DEFAULT 0,
|
||||
elo_change REAL,
|
||||
origin_elo REAL,
|
||||
rank_score INTEGER,
|
||||
is_win BOOLEAN,
|
||||
|
||||
@@ -291,6 +292,7 @@ CREATE TABLE IF NOT EXISTS fact_match_players_t (
|
||||
rws REAL,
|
||||
mvp_count INTEGER DEFAULT 0,
|
||||
elo_change REAL,
|
||||
origin_elo REAL,
|
||||
rank_score INTEGER,
|
||||
is_win BOOLEAN,
|
||||
kast REAL,
|
||||
@@ -400,6 +402,7 @@ CREATE TABLE IF NOT EXISTS fact_match_players_ct (
|
||||
rws REAL,
|
||||
mvp_count INTEGER DEFAULT 0,
|
||||
elo_change REAL,
|
||||
origin_elo REAL,
|
||||
rank_score INTEGER,
|
||||
is_win BOOLEAN,
|
||||
kast REAL,
|
||||
@@ -498,18 +501,27 @@ CREATE TABLE IF NOT EXISTS fact_rounds (
|
||||
match_id TEXT,
|
||||
round_num INTEGER,
|
||||
|
||||
-- 公共字段(两种数据源均有)
|
||||
winner_side TEXT CHECK(winner_side IN ('CT', 'T', 'None')),
|
||||
win_reason INTEGER, -- Raw integer from source
|
||||
win_reason_desc TEXT, -- Mapped description (e.g. 'TargetBombed')
|
||||
duration REAL,
|
||||
end_time_stamp TEXT,
|
||||
|
||||
ct_score INTEGER,
|
||||
t_score INTEGER,
|
||||
|
||||
-- Leetify Specific
|
||||
ct_money_start INTEGER,
|
||||
t_money_start INTEGER,
|
||||
-- Leetify专属字段
|
||||
ct_money_start INTEGER, -- 仅leetify
|
||||
t_money_start INTEGER, -- 仅leetify
|
||||
begin_ts TEXT, -- 仅leetify
|
||||
end_ts TEXT, -- 仅leetify
|
||||
|
||||
-- Classic专属字段
|
||||
end_time_stamp TEXT, -- 仅classic
|
||||
final_round_time INTEGER, -- 仅classic
|
||||
pasttime INTEGER, -- 仅classic
|
||||
|
||||
-- 数据源标记(继承自fact_matches)
|
||||
data_source_type TEXT CHECK(data_source_type IN ('leetify', 'classic', 'unknown')),
|
||||
|
||||
PRIMARY KEY (match_id, round_num),
|
||||
FOREIGN KEY (match_id) REFERENCES fact_matches(match_id) ON DELETE CASCADE
|
||||
@@ -540,17 +552,24 @@ CREATE TABLE IF NOT EXISTS fact_round_events (
|
||||
is_through_smoke BOOLEAN DEFAULT 0,
|
||||
is_noscope BOOLEAN DEFAULT 0,
|
||||
|
||||
-- Spatial Data (From RoundList)
|
||||
attacker_pos_x INTEGER,
|
||||
attacker_pos_y INTEGER,
|
||||
attacker_pos_z INTEGER,
|
||||
victim_pos_x INTEGER,
|
||||
victim_pos_y INTEGER,
|
||||
victim_pos_z INTEGER,
|
||||
-- Classic空间数据(xyz坐标)
|
||||
attacker_pos_x INTEGER, -- 仅classic
|
||||
attacker_pos_y INTEGER, -- 仅classic
|
||||
attacker_pos_z INTEGER, -- 仅classic
|
||||
victim_pos_x INTEGER, -- 仅classic
|
||||
victim_pos_y INTEGER, -- 仅classic
|
||||
victim_pos_z INTEGER, -- 仅classic
|
||||
|
||||
-- Economy/Score Impact (From Leetify)
|
||||
score_change_attacker REAL,
|
||||
score_change_victim REAL,
|
||||
-- Leetify评分影响
|
||||
score_change_attacker REAL, -- 仅leetify
|
||||
score_change_victim REAL, -- 仅leetify
|
||||
twin REAL, -- 仅leetify (team win probability)
|
||||
c_twin REAL, -- 仅leetify
|
||||
twin_change REAL, -- 仅leetify
|
||||
c_twin_change REAL, -- 仅leetify
|
||||
|
||||
-- 数据源标记
|
||||
data_source_type TEXT CHECK(data_source_type IN ('leetify', 'classic', 'unknown')),
|
||||
|
||||
FOREIGN KEY (match_id, round_num) REFERENCES fact_rounds(match_id, round_num) ON DELETE CASCADE
|
||||
);
|
||||
@@ -566,18 +585,54 @@ CREATE TABLE IF NOT EXISTS fact_round_player_economy (
|
||||
steam_id_64 TEXT,
|
||||
|
||||
side TEXT CHECK(side IN ('CT', 'T')),
|
||||
|
||||
-- Leetify经济数据(仅leetify)
|
||||
start_money INTEGER,
|
||||
equipment_value INTEGER,
|
||||
|
||||
-- Inventory Summary
|
||||
main_weapon TEXT,
|
||||
has_helmet BOOLEAN,
|
||||
has_defuser BOOLEAN,
|
||||
has_zeus BOOLEAN,
|
||||
|
||||
-- Round Performance Summary (Leetify)
|
||||
round_performance_score REAL,
|
||||
|
||||
-- Classic装备快照(仅classic, JSON存储)
|
||||
equipment_snapshot_json TEXT, -- Classic的equiped字段序列化
|
||||
|
||||
-- 数据源标记
|
||||
data_source_type TEXT CHECK(data_source_type IN ('leetify', 'classic', 'unknown')),
|
||||
|
||||
PRIMARY KEY (match_id, round_num, steam_id_64),
|
||||
FOREIGN KEY (match_id, round_num) REFERENCES fact_rounds(match_id, round_num) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- ==========================================
|
||||
-- Views for Aggregated Statistics
|
||||
-- ==========================================
|
||||
|
||||
-- 玩家全场景统计视图
|
||||
CREATE VIEW IF NOT EXISTS v_player_all_stats AS
|
||||
SELECT
|
||||
steam_id_64,
|
||||
COUNT(DISTINCT match_id) as total_matches,
|
||||
AVG(rating) as avg_rating,
|
||||
AVG(kd_ratio) as avg_kd,
|
||||
AVG(kast) as avg_kast,
|
||||
SUM(kills) as total_kills,
|
||||
SUM(deaths) as total_deaths,
|
||||
SUM(assists) as total_assists,
|
||||
SUM(mvp_count) as total_mvps
|
||||
FROM fact_match_players
|
||||
GROUP BY steam_id_64;
|
||||
|
||||
-- 地图维度统计视图
|
||||
CREATE VIEW IF NOT EXISTS v_map_performance AS
|
||||
SELECT
|
||||
fmp.steam_id_64,
|
||||
fm.map_name,
|
||||
COUNT(*) as matches_on_map,
|
||||
AVG(fmp.rating) as avg_rating,
|
||||
AVG(fmp.kd_ratio) as avg_kd,
|
||||
SUM(CASE WHEN fmp.is_win THEN 1 ELSE 0 END) * 1.0 / COUNT(*) as win_rate
|
||||
FROM fact_match_players fmp
|
||||
JOIN fact_matches fm ON fmp.match_id = fm.match_id
|
||||
GROUP BY fmp.steam_id_64, fm.map_name;
|
||||
|
||||
Reference in New Issue
Block a user