feat: implement pivot-currency model, rbac smart tokens & fix circular imports
This commit is contained in:
91
backend/app/diagnose_system.py
Normal file
91
backend/app/diagnose_system.py
Normal file
@@ -0,0 +1,91 @@
|
||||
import asyncio
|
||||
import os
|
||||
from sqlalchemy import text, select
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
# Importáljuk a rendszermodulokat az ellenőrzéshez
|
||||
try:
|
||||
from app.core.config import settings
|
||||
from app.core.i18n import t
|
||||
from app.models.system_config import SystemParameter
|
||||
except ImportError as e:
|
||||
print(f"❌ Import hiba: {e}")
|
||||
print("Ellenőrizd, hogy a PYTHONPATH be van-e állítva!")
|
||||
exit(1)
|
||||
|
||||
async def diagnose():
|
||||
print("\n" + "="*40)
|
||||
print("🔍 SZERVIZ KERESŐ - RENDSZER DIAGNOSZTIKA")
|
||||
print("="*40 + "\n")
|
||||
|
||||
engine = create_async_engine(settings.DATABASE_URL)
|
||||
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
async with async_session() as session:
|
||||
# --- 1. SÉMA ELLENŐRZÉSE ---
|
||||
print("1️⃣ Adatbázis séma ellenőrzése...")
|
||||
try:
|
||||
# Organizations tábla oszlopai
|
||||
org_res = await session.execute(text(
|
||||
"SELECT column_name FROM information_schema.columns "
|
||||
"WHERE table_schema = 'data' AND table_name = 'organizations';"
|
||||
))
|
||||
org_cols = [row[0] for row in org_res.fetchall()]
|
||||
|
||||
# Users tábla oszlopai
|
||||
user_res = await session.execute(text(
|
||||
"SELECT column_name FROM information_schema.columns "
|
||||
"WHERE table_schema = 'data' AND table_name = 'users';"
|
||||
))
|
||||
user_cols = [row[0] for row in user_res.fetchall()]
|
||||
|
||||
checks = [
|
||||
("organizations.language", "language" in org_cols),
|
||||
("organizations.default_currency", "default_currency" in org_cols),
|
||||
("users.preferred_language", "preferred_language" in user_cols),
|
||||
("system_parameters tábla létezik", True) # Ha idáig eljut, a SystemParameter import sikerült
|
||||
]
|
||||
|
||||
for label, success in checks:
|
||||
status = "✅ OK" if success else "❌ HIÁNYZIK"
|
||||
print(f" [{status}] {label}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ❌ Hiba a séma lekérdezésekor: {e}")
|
||||
|
||||
# --- 2. ADATOK ELLENŐRZÉSE ---
|
||||
print("\n2️⃣ System Parameters (Alapadatok) ellenőrzése...")
|
||||
try:
|
||||
result = await session.execute(select(SystemParameter))
|
||||
params = result.scalars().all()
|
||||
if params:
|
||||
print(f" ✅ Talált paraméterek: {len(params)} db")
|
||||
for p in params:
|
||||
print(f" - {p.key}: {p.value[:2]}... (+{len(p.value)-2} elem)")
|
||||
else:
|
||||
print(" ⚠️ Figyelem: A system_parameters tábla üres!")
|
||||
except Exception as e:
|
||||
print(f" ❌ Hiba az adatok lekérésekor: {e}")
|
||||
|
||||
# --- 3. NYELVI MOTOR ELLENŐRZÉSE ---
|
||||
print("\n3️⃣ Nyelvi motor (i18n) és hu.json ellenőrzése...")
|
||||
try:
|
||||
test_save = t("COMMON.SAVE")
|
||||
test_email = t("email.reg_greeting", first_name="Admin")
|
||||
|
||||
if test_save != "COMMON.SAVE":
|
||||
print(f" ✅ Fordítás sikeres: COMMON.SAVE -> '{test_save}'")
|
||||
print(f" ✅ Paraméteres fordítás: '{test_email}'")
|
||||
else:
|
||||
print(" ❌ A fordítás NEM működik (csak a kulcsot adta vissza).")
|
||||
print(f" Ellenőrizd a /app/app/locales/hu.json elérhetőségét!")
|
||||
except Exception as e:
|
||||
print(f" ❌ Hiba a nyelvi motor futtatásakor: {e}")
|
||||
|
||||
print("\n" + "="*40)
|
||||
print("✅ DIAGNOSZTIKA KÉSZ")
|
||||
print("="*40 + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(diagnose())
|
||||
Reference in New Issue
Block a user