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:
24
app/db.py
24
app/db.py
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user