修复普通用户对模型训练的权限操作
This commit is contained in:
@@ -570,6 +570,16 @@ class PlatformStore:
|
||||
""")
|
||||
except Exception:
|
||||
pass # 列不存在时忽略
|
||||
# 修复历史数据:为 eval_tasks 表回填 created_by(从 payload JSON 中提取)
|
||||
try:
|
||||
conn.execute("""
|
||||
UPDATE eval_tasks SET created_by = payload::json->>'created_by'
|
||||
WHERE (created_by IS NULL OR created_by = '')
|
||||
AND payload IS NOT NULL
|
||||
AND payload::json->>'created_by' IS NOT NULL
|
||||
""")
|
||||
except Exception:
|
||||
pass # 列或语法不支持时忽略
|
||||
# 清理超过 7 天的操作日志
|
||||
try:
|
||||
cutoff = (datetime.now(timezone.utc) - timedelta(days=7)).isoformat()
|
||||
@@ -2031,6 +2041,7 @@ class PlatformStore:
|
||||
"process_id": None,
|
||||
"train_duration": "",
|
||||
"create_time": now,
|
||||
"created_by": payload.get("created_by"),
|
||||
}
|
||||
with self.connect() as conn:
|
||||
conn.execute(
|
||||
@@ -2529,8 +2540,8 @@ class PlatformStore:
|
||||
if data.get("metric") == "custom":
|
||||
data["metric"] = data["metric_label"]
|
||||
conn.execute(
|
||||
"INSERT INTO eval_tasks (id, name, payload, status, create_time) VALUES (?, ?, ?, ?, ?)",
|
||||
(task_id, name, json_dumps(data), status, now),
|
||||
"INSERT INTO eval_tasks (id, name, payload, status, create_time, created_by) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
(task_id, name, json_dumps(data), status, now, data.get("created_by")),
|
||||
)
|
||||
return self.eval_task(task_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user