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

Function list_page

backend/apps/system/crud/system_variable.py:56–81  ·  view source on GitHub ↗
(session: SessionDep, trans: Trans, pageNum: int, pageSize: int, variable: SystemVariable)

Source from the content-addressed store, hash-verified

54
55
56async def list_page(session: SessionDep, trans: Trans, pageNum: int, pageSize: int, variable: SystemVariable):
57 pagination = PaginationParams(page=pageNum, size=pageSize)
58 paginator = Paginator(session)
59 filters = {}
60
61 if variable.name is None:
62 stmt = select(SystemVariable).order_by(SystemVariable.type.desc(), SystemVariable.name.asc())
63 else:
64 stmt = select(SystemVariable).where(
65 and_(SystemVariable.name.ilike(f'%{variable.name}%'), SystemVariable.type != 'system')).order_by(
66 SystemVariable.type.desc(), SystemVariable.name.asc())
67
68 variable_page = await paginator.get_paginated_response(
69 stmt=stmt,
70 pagination=pagination,
71 **filters)
72
73 res = []
74 for r in variable_page.items:
75 data = SystemVariable(**r)
76 if data.type == 'system':
77 data.name = trans(data.name)
78 res.append(data)
79
80 return {"items": res, "page": variable_page.page, "size": variable_page.size, "total": variable_page.total,
81 "total_pages": variable_page.total_pages}
82
83
84def checkName(session: SessionDep, trans: Trans, variable: SystemVariable):

Callers 1

pagerFunction · 0.90

Calls 5

PaginationParamsClass · 0.90
PaginatorClass · 0.90
SystemVariableClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected