diff --git a/scripts/analyze-req.json b/scripts/analyze-req.json new file mode 100644 index 0000000..b5d4d19 --- /dev/null +++ b/scripts/analyze-req.json @@ -0,0 +1 @@ +{"age":8,"gender":"м","terrain":["лес"],"elapsed_hours":2.0,"has_transport":"bike","season":"лето"} \ No newline at end of file diff --git a/scripts/e2e-analyze.sh b/scripts/e2e-analyze.sh new file mode 100644 index 0000000..5f5964d --- /dev/null +++ b/scripts/e2e-analyze.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# e2e ВЕКТОРА на CT108 после B14/B15-деплоя: login (form!) -> /analyze -> анализ результата +set -e +TOKEN=$(curl -s -m 8 -X POST localhost:8000/api/v1/auth/login \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data 'username=admin&password=pass123' \ + | python3 -c 'import sys,json; print(json.load(sys.stdin)["access_token"])') +echo "token: ${TOKEN:0:16}..." +echo "=== POST /analyze (bike 8yo 2h лес день) ===" +curl -s -m 90 -X POST localhost:8000/api/v1/analyze \ + -H "Authorization: Bearer $TOKEN" \ + -H 'Content-Type: application/json' --data @/tmp/analyze-req.json > /tmp/analyze-result.json +python3 - <<'PY' +import json +d = json.load(open('/tmp/analyze-result.json')) +print('max_distance_km:', d.get('max_distance_km')) +print('urgency:', d.get('urgency')) +print('coefficients:', d.get('coefficients')) +print('profiles:', [p.get('name') for p in d.get('active_profiles', [])]) +print('zones:', len(d.get('primary_zones', []))) +print('fallback_used:', d.get('fallback_used')) +assert abs(d['max_distance_km'] - 5.4) < 1e-6, 'REGRESSION: max_distance != 5.4' +print('REGRESSION 5.4 OK') +PY \ No newline at end of file diff --git a/scripts/login.json b/scripts/login.json new file mode 100644 index 0000000..048d0ec --- /dev/null +++ b/scripts/login.json @@ -0,0 +1 @@ +{"username":"admin","password":"pass123"} \ No newline at end of file diff --git a/scripts/prod-stamp-backfill.sql b/scripts/prod-stamp-backfill.sql new file mode 100644 index 0000000..ac059e5 --- /dev/null +++ b/scripts/prod-stamp-backfill.sql @@ -0,0 +1,10 @@ +-- Стамп-миграция: alembic_version ставится на 006, так как таблицы 006 +-- уже созданы (create_all по моделям B15 при старте контейнера). +-- Затем бэкфилл search_models из cases.analysis_log (idempotent). +INSERT INTO search_models (case_id, version, input_snapshot, model_json) +SELECT c.id, 1, NULL, c.analysis_log +FROM cases c +WHERE c.analysis_log IS NOT NULL + AND jsonb_typeof(c.analysis_log) = 'object' + AND c.analysis_log ? 'primary_zones' + AND NOT EXISTS (SELECT 1 FROM search_models sm WHERE sm.case_id = c.id AND sm.version = 1); \ No newline at end of file