add bet impact simulator, visitor log page, and fix console logging

- Bet impact simulator on /predictions shows rank headroom and safe bet amounts
- Password-protected /visitors page with visitor log table and stats
- Console now logs real visitor IPs instead of Cloudflare tunnel IPs
This commit is contained in:
2026-02-26 10:19:14 +05:00
parent 86865166ef
commit 9762c0f9bf
4 changed files with 307 additions and 2 deletions

View File

@@ -177,6 +177,30 @@ def insert_visitors(batch: list[dict]):
)
@_with_lock
def get_recent_visitors(limit: int = 200) -> list[dict]:
"""Get recent visitor log entries."""
client = get_client()
result = client.query(
"SELECT ip, country, path, method, user_agent, referer, accept_lang, created_at "
"FROM visitors ORDER BY created_at DESC LIMIT {limit:UInt32}",
parameters={"limit": limit},
)
visitors = []
for row in result.result_rows:
visitors.append({
"ip": row[0],
"country": row[1],
"path": row[2],
"method": row[3],
"user_agent": row[4],
"referer": row[5],
"accept_lang": row[6],
"created_at": str(row[7]),
})
return visitors
@_with_lock
def get_recent_games(n: int = 50) -> list[dict]:
"""Get last N completed games."""