@@ -45,7 +45,8 @@ async def pager(session: SessionDep, current_user: CurrentUser, current_page: in
4545
4646@router .put ("" , response_model = int , summary = f"{ PLACEHOLDER_PREFIX } create_or_update_dt" )
4747@require_permissions (permission = SqlbotPermission (role = ['ws_admin' ], type = 'ds' , keyExpression = "info.datasource" ))
48- @system_log (LogConfig (operation_type = OperationType .CREATE_OR_UPDATE , module = OperationModules .DATA_TRAINING ,resource_id_expr = 'info.id' , result_id_expr = "result_self" ))
48+ @system_log (LogConfig (operation_type = OperationType .CREATE_OR_UPDATE , module = OperationModules .DATA_TRAINING ,
49+ resource_id_expr = 'info.id' , result_id_expr = "result_self" ))
4950async def create_or_update (session : SessionDep , current_user : CurrentUser , trans : Trans , info : DataTrainingInfo ):
5051 oid = current_user .oid
5152 if info .id :
@@ -55,14 +56,16 @@ async def create_or_update(session: SessionDep, current_user: CurrentUser, trans
5556
5657
5758@router .delete ("" , summary = f"{ PLACEHOLDER_PREFIX } delete_dt" )
58- @system_log (LogConfig (operation_type = OperationType .DELETE , module = OperationModules .DATA_TRAINING ,resource_id_expr = 'id_list' ))
59+ @system_log (
60+ LogConfig (operation_type = OperationType .DELETE , module = OperationModules .DATA_TRAINING , resource_id_expr = 'id_list' ))
5961@require_permissions (permission = SqlbotPermission (role = ['ws_admin' ]))
6062async def delete (session : SessionDep , id_list : list [int ]):
6163 delete_training (session , id_list )
6264
6365
6466@router .get ("/{id}/enable/{enabled}" , summary = f"{ PLACEHOLDER_PREFIX } enable_dt" )
65- @system_log (LogConfig (operation_type = OperationType .UPDATE , module = OperationModules .DATA_TRAINING ,resource_id_expr = 'id' ))
67+ @system_log (
68+ LogConfig (operation_type = OperationType .UPDATE , module = OperationModules .DATA_TRAINING , resource_id_expr = 'id' ))
6669@require_permissions (permission = SqlbotPermission (role = ['ws_admin' ]))
6770async def enable (session : SessionDep , id : int , enabled : bool , trans : Trans ):
6871 enable_training (session , id , enabled , trans )
@@ -89,9 +92,7 @@ def inner():
8992 fields .append (AxisObj (name = trans ('i18n_data_training.problem_description' ), value = 'question' ))
9093 fields .append (AxisObj (name = trans ('i18n_data_training.sample_sql' ), value = 'description' ))
9194 fields .append (AxisObj (name = trans ('i18n_data_training.effective_data_sources' ), value = 'datasource_name' ))
92- if current_user .oid == 1 :
93- fields .append (
94- AxisObj (name = trans ('i18n_data_training.advanced_application' ), value = 'advanced_application_name' ))
95+ fields .append (AxisObj (name = trans ('i18n_data_training.advanced_application' ), value = 'advanced_application_name' ))
9596
9697 md_data , _fields_list = DataFormat .convert_object_array_for_pandas (fields , data_list )
9798
@@ -127,10 +128,9 @@ def inner():
127128 fields .append (AxisObj (name = trans ('i18n_data_training.sample_sql_template' ), value = 'description' ))
128129 fields .append (
129130 AxisObj (name = trans ('i18n_data_training.effective_data_sources_template' ), value = 'datasource_name' ))
130- if current_user .oid == 1 :
131- fields .append (
132- AxisObj (name = trans ('i18n_data_training.advanced_application_template' ),
133- value = 'advanced_application_name' ))
131+ fields .append (
132+ AxisObj (name = trans ('i18n_data_training.advanced_application_template' ),
133+ value = 'advanced_application_name' ))
134134
135135 md_data , _fields_list = DataFormat .convert_object_array_for_pandas (fields , data_list )
136136
@@ -175,10 +175,7 @@ async def upload_excel(trans: Trans, current_user: CurrentUser, file: UploadFile
175175
176176 oid = current_user .oid
177177
178- use_cols = [0 , 1 , 2 ] # 问题, 描述, 数据源名称
179- # 根据oid确定要读取的列
180- if oid == 1 :
181- use_cols = [0 , 1 , 2 , 3 ] # 问题, 描述, 数据源名称, 高级应用名称
178+ use_cols = [0 , 1 , 2 , 3 ] # 问题, 描述, 数据源名称, 高级应用名称
182179
183180 def inner ():
184181
@@ -211,19 +208,14 @@ def inner():
211208 description = row [1 ].strip () if pd .notna (row [1 ]) and row [1 ].strip () else ''
212209 datasource_name = row [2 ].strip () if pd .notna (row [2 ]) and row [2 ].strip () else ''
213210
214- advanced_application_name = ''
215- if oid == 1 and len (row ) > 3 :
211+ advanced_application_name = None
212+ if len (row ) > 3 :
216213 advanced_application_name = row [3 ].strip () if pd .notna (row [3 ]) and row [3 ].strip () else ''
217214
218- if oid == 1 :
219- import_data .append (
220- DataTrainingInfo (oid = oid , question = question , description = description ,
221- datasource_name = datasource_name ,
222- advanced_application_name = advanced_application_name ))
223- else :
224- import_data .append (
225- DataTrainingInfo (oid = oid , question = question , description = description ,
226- datasource_name = datasource_name ))
215+ import_data .append (
216+ DataTrainingInfo (oid = oid , question = question , description = description ,
217+ datasource_name = datasource_name ,
218+ advanced_application_name = advanced_application_name ))
227219
228220 res = batch_create_training (session , import_data , oid , trans )
229221
@@ -247,9 +239,8 @@ def inner():
247239 fields .append (AxisObj (name = trans ('i18n_data_training.problem_description' ), value = 'question' ))
248240 fields .append (AxisObj (name = trans ('i18n_data_training.sample_sql' ), value = 'description' ))
249241 fields .append (AxisObj (name = trans ('i18n_data_training.effective_data_sources' ), value = 'datasource_name' ))
250- if current_user .oid == 1 :
251- fields .append (
252- AxisObj (name = trans ('i18n_data_training.advanced_application' ), value = 'advanced_application_name' ))
242+ fields .append (
243+ AxisObj (name = trans ('i18n_data_training.advanced_application' ), value = 'advanced_application_name' ))
253244 fields .append (AxisObj (name = trans ('i18n_data_training.error_info' ), value = 'errors' ))
254245
255246 md_data , _fields_list = DataFormat .convert_object_array_for_pandas (fields , data_list )
0 commit comments