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

Function getGroupListCount

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

Source from the content-addressed store, hash-verified

143}
144
145export async function getGroupListCount({
146 projectId,
147 type,
148 search,
149}: {
150 projectId: string;
151 type?: string;
152 search?: string;
153}): Promise<number> {
154 const conditions = [
155 `project_id = ${sqlstring.escape(projectId)}`,
156 'deleted = 0',
157 ...(type ? [`type = ${sqlstring.escape(type)}`] : []),
158 ...(search
159 ? [
160 `(name ILIKE ${sqlstring.escape(`%${search}%`)} OR id ILIKE ${sqlstring.escape(`%${search}%`)})`,
161 ]
162 : []),
163 ];
164
165 const rows = await chQuery<{ count: number }>(`
166 SELECT count() as count
167 FROM ${TABLE_NAMES.groups} FINAL
168 WHERE ${conditions.join(' AND ')}
169 `);
170 return rows[0]?.count ?? 0;
171}
172
173export async function getGroupTypes(projectId: string): Promise<string[]> {
174 const rows = await chQuery<{ type: string }>(`

Callers 1

group.tsFile · 0.90

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected