1.0.0 : Web Implemented.

This commit is contained in:
2026-01-26 02:13:06 +08:00
parent 026a8fe65d
commit 8dabf0b097
55 changed files with 4545 additions and 3 deletions

65
scripts/debug_db.py Normal file
View File

@@ -0,0 +1,65 @@
import sqlite3
import os
# Define database paths
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
L2_PATH = os.path.join(BASE_DIR, 'database', 'L2', 'L2_Main.sqlite')
def check_l2_tables():
print(f"Checking L2 database at: {L2_PATH}")
if not os.path.exists(L2_PATH):
print("Error: L2 database not found!")
return
conn = sqlite3.connect(L2_PATH)
cursor = conn.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
print("Tables in L2 Database:")
for table in tables:
print(f" - {table[0]}")
conn.close()
def debug_player_query(player_name_query=None):
print(f"\nDebugging Player Query (L2)...")
conn = sqlite3.connect(L2_PATH)
cursor = conn.cursor()
try:
# Check if 'dim_players' exists
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='dim_players';")
if not cursor.fetchone():
print("Error: 'dim_players' table not found!")
return
# Check schema of dim_players
print("\nChecking dim_players schema:")
cursor.execute("PRAGMA table_info(dim_players)")
for col in cursor.fetchall():
print(col)
# Check sample data
print("\nSampling dim_players (first 5):")
cursor.execute("SELECT * FROM dim_players LIMIT 5")
for row in cursor.fetchall():
print(row)
# Test Search
search_term = 'zy'
print(f"\nTesting search for '{search_term}':")
cursor.execute("SELECT * FROM dim_players WHERE name LIKE ?", (f'%{search_term}%',))
results = cursor.fetchall()
print(f"Found {len(results)} matches.")
for r in results:
print(r)
except Exception as e:
print(f"Error querying L2: {e}")
finally:
conn.close()
if __name__ == '__main__':
check_l2_tables()
debug_player_query()

View File

@@ -0,0 +1,34 @@
import sqlite3
import os
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
L2_PATH = os.path.join(BASE_DIR, 'database', 'L2', 'L2_Main.sqlite')
def check_db_integrity():
print(f"Checking DB at: {L2_PATH}")
if not os.path.exists(L2_PATH):
print("CRITICAL: Database file does not exist!")
return
try:
conn = sqlite3.connect(L2_PATH)
cursor = conn.cursor()
# Check integrity
print("Running PRAGMA integrity_check...")
cursor.execute("PRAGMA integrity_check")
print(f"Integrity: {cursor.fetchone()}")
# Check specific user again
cursor.execute("SELECT steam_id_64, username FROM dim_players WHERE username LIKE '%jacky%'")
rows = cursor.fetchall()
print(f"Direct DB check found {len(rows)} rows matching '%jacky%':")
for r in rows:
print(r)
conn.close()
except Exception as e:
print(f"DB Error: {e}")
if __name__ == '__main__':
check_db_integrity()

39
scripts/debug_jacky.py Normal file
View File

@@ -0,0 +1,39 @@
import sqlite3
import os
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
L2_PATH = os.path.join(BASE_DIR, 'database', 'L2', 'L2_Main.sqlite')
def check_jacky():
print(f"Checking L2 database at: {L2_PATH}")
conn = sqlite3.connect(L2_PATH)
cursor = conn.cursor()
search_term = 'jacky'
print(f"\nSearching for '%{search_term}%' (Case Insensitive test):")
# Standard LIKE
cursor.execute("SELECT steam_id_64, username FROM dim_players WHERE username LIKE ?", (f'%{search_term}%',))
results = cursor.fetchall()
print(f"LIKE results: {len(results)}")
for r in results:
print(r)
# Case insensitive explicit
print("\nSearching with LOWER():")
cursor.execute("SELECT steam_id_64, username FROM dim_players WHERE LOWER(username) LIKE LOWER(?)", (f'%{search_term}%',))
results_lower = cursor.fetchall()
print(f"LOWER() results: {len(results_lower)}")
for r in results_lower:
print(r)
# Check jacky0987 specifically
print("\nChecking specific username 'jacky0987':")
cursor.execute("SELECT steam_id_64, username FROM dim_players WHERE username = 'jacky0987'")
specific = cursor.fetchone()
print(f"Specific match: {specific}")
conn.close()
if __name__ == '__main__':
check_jacky()

84
scripts/init_web_db.py Normal file
View File

@@ -0,0 +1,84 @@
import sqlite3
import os
# Define database path
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
DB_PATH = os.path.join(BASE_DIR, 'database', 'Web', 'Web_App.sqlite')
def init_db():
print(f"Initializing Web database at: {DB_PATH}")
# Create directory if not exists
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Create Tables
tables = [
"""
CREATE TABLE IF NOT EXISTS team_lineups (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT,
player_ids_json TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
""",
"""
CREATE TABLE IF NOT EXISTS player_metadata (
steam_id_64 TEXT PRIMARY KEY,
notes TEXT,
tags TEXT,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
""",
"""
CREATE TABLE IF NOT EXISTS strategy_boards (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
map_name TEXT,
data_json TEXT,
created_by TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
""",
"""
CREATE TABLE IF NOT EXISTS wiki_pages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
path TEXT UNIQUE,
title TEXT,
content TEXT,
updated_by TEXT,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
""",
"""
CREATE TABLE IF NOT EXISTS comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT,
username TEXT,
target_type TEXT,
target_id TEXT,
content TEXT,
likes INTEGER DEFAULT 0,
is_hidden INTEGER DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
"""
]
for sql in tables:
try:
cursor.execute(sql)
print("Executed SQL successfully.")
except Exception as e:
print(f"Error executing SQL: {e}")
conn.commit()
conn.close()
print("Web database initialized successfully.")
if __name__ == '__main__':
init_db()