MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getGroupList

Function getGroupList

packages/db/src/services/group.service.ts:110–143  ·  view source on GitHub ↗
({
  projectId,
  cursor,
  take,
  search,
  type,
}: {
  projectId: string;
  cursor?: number;
  take: number;
  search?: string;
  type?: string;
})

Source from the content-addressed store, hash-verified

108}
109
110export async function getGroupList({
111 projectId,
112 cursor,
113 take,
114 search,
115 type,
116}: {
117 projectId: string;
118 cursor?: number;
119 take: number;
120 search?: string;
121 type?: string;
122}): Promise<IServiceGroup[]> {
123 const conditions = [
124 `project_id = ${sqlstring.escape(projectId)}`,
125 'deleted = 0',
126 ...(type ? [`type = ${sqlstring.escape(type)}`] : []),
127 ...(search
128 ? [
129 `(name ILIKE ${sqlstring.escape(`%${search}%`)} OR id ILIKE ${sqlstring.escape(`%${search}%`)})`,
130 ]
131 : []),
132 ];
133
134 const rows = await chQuery<IClickhouseGroup>(`
135 SELECT project_id, id, type, name, properties, created_at, version
136 FROM ${TABLE_NAMES.groups} FINAL
137 WHERE ${conditions.join(' AND ')}
138 ORDER BY created_at DESC
139 LIMIT ${take}
140 OFFSET ${Math.max(0, (cursor ?? 0) * take)}
141 `);
142 return rows.map(transformGroup);
143}
144
145export async function getGroupListCount({
146 projectId,

Callers 3

registerGroupToolsFunction · 0.90
group.tsFile · 0.90
findGroupsCoreFunction · 0.85

Calls 2

joinMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected