Balance signal (15% weight) favors under-represented chairs over last 50 games. Visitor middleware captures real IPs from CF headers, batched into ClickHouse with 90-day TTL.
56 lines
1.4 KiB
SQL
56 lines
1.4 KiB
SQL
CREATE TABLE IF NOT EXISTS games (
|
|
game_no UInt64,
|
|
winner UInt8,
|
|
total_pot UInt64,
|
|
bet_a UInt64,
|
|
bet_b UInt64,
|
|
bet_c UInt64,
|
|
hand_a String,
|
|
hand_b String,
|
|
hand_c String,
|
|
hand_type_a UInt8,
|
|
hand_type_b UInt8,
|
|
hand_type_c UInt8,
|
|
cards_json String,
|
|
duration_s UInt32,
|
|
created_at DateTime DEFAULT now()
|
|
) ENGINE = ReplacingMergeTree()
|
|
ORDER BY game_no;
|
|
|
|
CREATE TABLE IF NOT EXISTS bets (
|
|
game_no UInt64,
|
|
user_id UInt64,
|
|
chair UInt8,
|
|
bet_amount UInt64,
|
|
total_bet UInt64,
|
|
created_at DateTime64(3) DEFAULT now64(3)
|
|
) ENGINE = MergeTree()
|
|
ORDER BY (game_no, user_id, created_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
user_id UInt64,
|
|
nick_name String,
|
|
rich_level UInt16,
|
|
actor_level UInt16,
|
|
gender UInt8,
|
|
consume_total UInt64,
|
|
earn_total UInt64,
|
|
is_actor UInt8,
|
|
portrait String,
|
|
updated_at DateTime DEFAULT now()
|
|
) ENGINE = ReplacingMergeTree(updated_at)
|
|
ORDER BY user_id;
|
|
|
|
CREATE TABLE IF NOT EXISTS visitors (
|
|
ip String,
|
|
country String,
|
|
path String,
|
|
method String,
|
|
user_agent String,
|
|
referer String,
|
|
accept_lang String,
|
|
created_at DateTime DEFAULT now()
|
|
) ENGINE = MergeTree()
|
|
ORDER BY (created_at, ip)
|
|
TTL created_at + INTERVAL 90 DAY;
|