add balance/mean-reversion signal and Cloudflare visitor logging

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.
This commit is contained in:
2026-02-26 09:59:27 +05:00
parent 5fd4894599
commit 86865166ef
4 changed files with 135 additions and 9 deletions

View File

@@ -40,3 +40,16 @@ CREATE TABLE IF NOT EXISTS users (
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;