🧪 Smoke-test: 10/10 PASSED — волна 1 + волна 2
Покрытие (10 сценариев): - pronunciation_pool_stress — утечка пула - hints_db_increment — списание подсказок - game_complete_level_full_flow — идемпотентность + score - wordquiz_correct_answer — total_score растёт - wordquiz_wrong_answer — current_mistakes растёт - bubblewords_complete_flow — levels + score - sentences_check_wrong — неверный ответ не начисляет - typing_progress_flow — typing_progress записан - users_set_language — app_language меняется - achievements_track_login — daily_logins растёт Результат: 10/10 PASSED за 0.79s. Робот подтверждает: большинство находок AI-ревью по этим разделам — галлюцинации. Инвентаризация: - scripts/dump_inventory.py — собирает эндпоинты + схему - endpoints_inventory.md — 105 эндпоинтов - database_schema.md — 40 таблиц
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Инвентаризация проекта: все эндпоинты + схема базы.
|
||||
|
||||
Запуск: python scripts/dump_inventory.py
|
||||
Результат: endpoints_inventory.md + database_schema.md
|
||||
"""
|
||||
import asyncio
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from database import get_pool
|
||||
|
||||
|
||||
def dump_endpoints() -> None:
|
||||
"""Собирает все эндпоинты из routers/*.py."""
|
||||
routers_dir = Path("routers")
|
||||
lines = ["# 🛣 Все эндпоинты проекта", ""]
|
||||
total = 0
|
||||
|
||||
for router_file in sorted(routers_dir.glob("*.py")):
|
||||
if router_file.name == "__init__.py":
|
||||
continue
|
||||
|
||||
content = router_file.read_text(encoding="utf-8")
|
||||
|
||||
prefix_match = re.search(r'APIRouter\(prefix="([^"]+)"', content)
|
||||
prefix = prefix_match.group(1) if prefix_match else ""
|
||||
|
||||
endpoints = re.findall(
|
||||
r'@router\.(get|post|put|delete|patch)\("([^"]+)"',
|
||||
content,
|
||||
)
|
||||
|
||||
if endpoints:
|
||||
lines.append(f"## {router_file.name}")
|
||||
lines.append(f"**Префикс:** `{prefix}`")
|
||||
lines.append("")
|
||||
for method, path in endpoints:
|
||||
full_path = f"{prefix}{path}" if path.startswith("/") else f"{prefix}/{path}"
|
||||
lines.append(f"- `{method.upper()} {full_path}`")
|
||||
total += 1
|
||||
lines.append("")
|
||||
|
||||
Path("endpoints_inventory.md").write_text("\n".join(lines), encoding="utf-8")
|
||||
print(f"✅ endpoints_inventory.md — {total} эндпоинтов")
|
||||
|
||||
|
||||
async def dump_schema() -> None:
|
||||
"""Собирает все таблицы и колонки из базы."""
|
||||
pool = await get_pool()
|
||||
async with pool.acquire() as conn:
|
||||
tables = await conn.fetch("""
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_type = 'BASE TABLE'
|
||||
ORDER BY table_name
|
||||
""")
|
||||
|
||||
lines = ["# 🗄 Схема базы данных", ""]
|
||||
total = 0
|
||||
|
||||
for t in tables:
|
||||
table_name = t["table_name"]
|
||||
lines.append(f"## {table_name}")
|
||||
lines.append("")
|
||||
|
||||
cols = await conn.fetch("""
|
||||
SELECT column_name, data_type, is_nullable, column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = $1
|
||||
ORDER BY ordinal_position
|
||||
""", table_name)
|
||||
|
||||
lines.append("| Колонка | Тип | NULL | Default |")
|
||||
lines.append("|---------|-----|------|---------|")
|
||||
for c in cols:
|
||||
nullable = "YES" if c["is_nullable"] == "YES" else "NO"
|
||||
default = (c["column_default"] or "")[:50]
|
||||
lines.append(f"| {c['column_name']} | {c['data_type']} | {nullable} | {default} |")
|
||||
lines.append("")
|
||||
total += 1
|
||||
|
||||
await pool.close()
|
||||
|
||||
Path("database_schema.md").write_text("\n".join(lines), encoding="utf-8")
|
||||
print(f"✅ database_schema.md — {total} таблиц")
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
dump_endpoints()
|
||||
await dump_schema()
|
||||
print("🎉 Готово!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user