v1.0.95: full test data — op_uid, user_email, app_version, params saved to runs
This commit is contained in:
+16
-9
@@ -234,7 +234,7 @@ def api_test():
|
||||
client.post(f"/instanceOperations/{op_uid}/run")
|
||||
|
||||
# фоном ждать завершения
|
||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, True, get_client_id(), get_stand()), daemon=True).start()
|
||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, True, get_client_id(), get_stand(), params), daemon=True).start()
|
||||
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
|
||||
|
||||
else:
|
||||
@@ -264,7 +264,7 @@ def api_test():
|
||||
# Получить реальное имя инстанса из API (не UUID!)
|
||||
if not display_name:
|
||||
display_name = _get_instance_display_name(client, instance_uid)
|
||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, get_client_id(), get_stand(), is_delete), daemon=True).start()
|
||||
threading.Thread(target=_finish_op, args=(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, False, get_client_id(), get_stand(), is_delete, params), daemon=True).start()
|
||||
return jsonify({"status": "RUNNING", "opUid": op_uid, "instanceUid": instance_uid, "displayName": display_name})
|
||||
|
||||
except Exception as e:
|
||||
@@ -303,7 +303,7 @@ def _get_instance_display_name(client, instance_uid):
|
||||
return instance_uid
|
||||
|
||||
|
||||
def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, client_id, stand, is_delete=False):
|
||||
def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_op_id, is_create, client_id, stand, is_delete=False, params=None):
|
||||
"""Фоном ждать dtFinish и сохранить результат."""
|
||||
import time
|
||||
_cleanup_op_results() # очистить старые записи перед добавлением новой
|
||||
@@ -344,13 +344,18 @@ def _finish_op(client, op_uid, instance_uid, svc_id, display_name, op_name, svc_
|
||||
# Сохранить в БД историю
|
||||
try:
|
||||
from db.save_run import save_run
|
||||
save_run(client_id, stand, svc_id, op.get("svc", ""), op_name, svc_op_id,
|
||||
instance_uid, display_name,
|
||||
from api.auth import get_token_info
|
||||
user = get_token_info()
|
||||
save_run(client_id, stand,
|
||||
user.get("email", ""),
|
||||
svc_id, op.get("svc", ""), op_name, svc_op_id,
|
||||
op_uid, instance_uid, display_name,
|
||||
"OK" if is_ok else "FAIL",
|
||||
round(time.time() - t0, 1),
|
||||
str(err) if err else "",
|
||||
{}, # params недоступны в _finish_op — будут при следующем улучшении
|
||||
op.get("stages", []))
|
||||
params or {},
|
||||
op.get("stages", []),
|
||||
current_app.config.get("VERSION", ""))
|
||||
except Exception:
|
||||
pass # не ронять фоновый поток из-за БД
|
||||
return
|
||||
@@ -413,8 +418,10 @@ def api_history():
|
||||
return jsonify([])
|
||||
cur = conn.cursor()
|
||||
cur.execute("""
|
||||
SELECT id, created_at, client_id, stand, svc_id, svc_name,
|
||||
op_name, instance_uid, display_name, status, duration_sec, error_log
|
||||
SELECT id, created_at, client_id, stand, user_email,
|
||||
svc_id, svc_name, op_name, svc_op_id, op_uid,
|
||||
instance_uid, display_name,
|
||||
status, duration_sec, error_log, app_version
|
||||
FROM runs
|
||||
WHERE client_id = %s AND stand = %s
|
||||
ORDER BY created_at DESC
|
||||
|
||||
Reference in New Issue
Block a user