MCPcopy Index your code
hub / github.com/dataease/SQLBot / user_ws_options

Function user_ws_options

backend/apps/system/crud/user.py:47–65  ·  view source on GitHub ↗
(session: Session, uid: int, trans: Optional[I18n] = None)

Source from the content-addressed store, hash-verified

45 return db_user
46
47async def user_ws_options(session: Session, uid: int, trans: Optional[I18n] = None) -> list[UserWs]:
48 if uid == 1:
49 stmt = select(WorkspaceModel.id, WorkspaceModel.name).order_by(WorkspaceModel.name, WorkspaceModel.create_time)
50 else:
51 stmt = select(WorkspaceModel.id, WorkspaceModel.name).join(
52 UserWsModel, UserWsModel.oid == WorkspaceModel.id
53 ).where(
54 UserWsModel.uid == uid,
55 ).order_by(WorkspaceModel.name, WorkspaceModel.create_time)
56 result = session.exec(stmt)
57 if not trans:
58 return result.all()
59 list_result = [
60 UserWs(id = id, name = trans(name) if name.startswith('i18n') else name)
61 for id, name in result.all()
62 ]
63 if list_result:
64 list_result.sort(key=lambda x: x.name)
65 return list_result
66
67@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
68async def single_delete(session: SessionDep, id: int):

Callers 4

ws_listFunction · 0.90
ws_optionsFunction · 0.90
ws_changeFunction · 0.90
queryFunction · 0.90

Calls 2

UserWsClass · 0.90
execMethod · 0.45

Tested by

no test coverage detected