mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 09:17:06 +08:00
perf: Optimize the speed of data querying
This commit is contained in:
@@ -384,17 +384,19 @@ def get_table_schema(session: SessionDep, current_user: CurrentUser, ds: CoreDat
|
||||
else:
|
||||
schema_table += f", {table_comment}\n[\n"
|
||||
|
||||
field_list = []
|
||||
for field in obj.fields:
|
||||
field_comment = ''
|
||||
if field.custom_comment:
|
||||
field_comment = field.custom_comment.strip()
|
||||
if field_comment == '':
|
||||
field_list.append(f"({field.field_name}:{field.field_type})")
|
||||
else:
|
||||
field_list.append(f"({field.field_name}:{field.field_type}, {field_comment})")
|
||||
schema_table += ",\n".join(field_list)
|
||||
schema_table += '\n]\n'
|
||||
if obj.fields:
|
||||
field_list = []
|
||||
for field in obj.fields:
|
||||
field_comment = ''
|
||||
if field.custom_comment:
|
||||
field_comment = field.custom_comment.strip()
|
||||
if field_comment == '':
|
||||
field_list.append(f"({field.field_name}:{field.field_type})")
|
||||
else:
|
||||
field_list.append(f"({field.field_name}:{field.field_type}, {field_comment})")
|
||||
schema_table += ",\n".join(field_list)
|
||||
schema_table += '\n]\n'
|
||||
|
||||
t_obj = {"id": obj.table.id, "schema_table": schema_table}
|
||||
tables.append(t_obj)
|
||||
all_tables.append(t_obj)
|
||||
|
||||
@@ -37,6 +37,7 @@ def get_row_permission_filters(session: SessionDep, current_user: CurrentUser, d
|
||||
if p_list is not None and u_list is not None and permission.id in p_list and (
|
||||
current_user.id in u_list or f'{current_user.id}' in u_list):
|
||||
flag = True
|
||||
break
|
||||
if flag:
|
||||
res.append(transRecord2DTO(session, permission))
|
||||
where_str = transFilterTree(session, res, ds)
|
||||
@@ -64,6 +65,7 @@ def get_column_permission_fields(session: SessionDep, current_user: CurrentUser,
|
||||
if p_list is not None and u_list is not None and permission.id in p_list and (
|
||||
current_user.id in u_list or f'{current_user.id}' in u_list):
|
||||
flag = True
|
||||
break
|
||||
if flag:
|
||||
permission_list = json.loads(permission.permissions)
|
||||
fields = filter_list(fields, permission_list)
|
||||
|
||||
Reference in New Issue
Block a user