diff --git a/apps/start/src/routes/_app.$organizationId.$projectId.groups_.$groupId._tabs.members.tsx b/apps/start/src/routes/_app.$organizationId.$projectId.groups_.$groupId._tabs.members.tsx index 12468c40..edf058d9 100644 --- a/apps/start/src/routes/_app.$organizationId.$projectId.groups_.$groupId._tabs.members.tsx +++ b/apps/start/src/routes/_app.$organizationId.$projectId.groups_.$groupId._tabs.members.tsx @@ -25,7 +25,7 @@ function Component() { ...trpc.group.listProfiles.queryOptions({ projectId, groupId, - cursor: page - 1, + cursor: (page - 1) * 50, take: 50, search: debouncedSearch || undefined, }), diff --git a/packages/db/src/buffers/profile-buffer.ts b/packages/db/src/buffers/profile-buffer.ts index 334869d1..6ff7c00b 100644 --- a/packages/db/src/buffers/profile-buffer.ts +++ b/packages/db/src/buffers/profile-buffer.ts @@ -65,8 +65,8 @@ export class ProfileBuffer extends BaseBuffer { ): Promise { const lockKey = `profile-lock:${projectId}:${profileId}`; const lockId = generateSecureId('lock'); - const maxRetries = 10; - const retryDelayMs = 25; + const maxRetries = 20; + const retryDelayMs = 50; for (let i = 0; i < maxRetries; i++) { const acquired = await this.redis.set(lockKey, lockId, 'EX', 5, 'NX'); diff --git a/packages/db/src/services/group.service.ts b/packages/db/src/services/group.service.ts index d3b46c82..e966cabc 100644 --- a/packages/db/src/services/group.service.ts +++ b/packages/db/src/services/group.service.ts @@ -102,6 +102,7 @@ export async function getGroupById( FROM ${TABLE_NAMES.groups} FINAL WHERE project_id = ${sqlstring.escape(projectId)} AND id = ${sqlstring.escape(id)} + AND deleted = 0 `); return rows[0] ? transformGroup(rows[0]) : null; } @@ -121,6 +122,7 @@ export async function getGroupList({ }): Promise { const conditions = [ `project_id = ${sqlstring.escape(projectId)}`, + 'deleted = 0', ...(type ? [`type = ${sqlstring.escape(type)}`] : []), ...(search ? [ @@ -151,6 +153,7 @@ export async function getGroupListCount({ }): Promise { const conditions = [ `project_id = ${sqlstring.escape(projectId)}`, + 'deleted = 0', ...(type ? [`type = ${sqlstring.escape(type)}`] : []), ...(search ? [ @@ -172,6 +175,7 @@ export async function getGroupTypes(projectId: string): Promise { SELECT DISTINCT type FROM ${TABLE_NAMES.groups} FINAL WHERE project_id = ${sqlstring.escape(projectId)} + AND deleted = 0 `); return rows.map((r) => r.type); } @@ -239,6 +243,7 @@ export async function getGroupPropertyKeys( SELECT DISTINCT arrayJoin(mapKeys(properties)) as key FROM ${TABLE_NAMES.groups} FINAL WHERE project_id = ${sqlstring.escape(projectId)} + AND deleted = 0 `); return rows.map((r) => r.key).sort(); } @@ -274,7 +279,7 @@ export async function getGroupMemberProfiles({ take: number; search?: string; }): Promise<{ data: IServiceProfile[]; count: number }> { - const offset = Math.max(0, (cursor ?? 0) * take); + const offset = Math.max(0, cursor ?? 0); const searchCondition = search?.trim() ? `AND (email ILIKE ${sqlstring.escape(`%${search.trim()}%`)} OR first_name ILIKE ${sqlstring.escape(`%${search.trim()}%`)} OR last_name ILIKE ${sqlstring.escape(`%${search.trim()}%`)})` : ''; diff --git a/packages/trpc/src/routers/chart.ts b/packages/trpc/src/routers/chart.ts index 1eec7dde..6699c7ff 100644 --- a/packages/trpc/src/routers/chart.ts +++ b/packages/trpc/src/routers/chart.ts @@ -374,6 +374,7 @@ export const chartRouter = createTRPCRouter({ .select<{ values: string }>([`distinct ${selectExpr} as values`]) .from(TABLE_NAMES.groups, true) .where('project_id', '=', projectId) + .where('deleted', '=', 0) .where(selectExpr, '!=', '') .where(selectExpr, 'IS NOT NULL', null) .orderBy('created_at', 'DESC')