This commit is contained in:
Carl-Gerhard Lindesvärd
2026-03-06 09:11:09 +01:00
parent 90881e5ffb
commit 289ffb7d6d
4 changed files with 10 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ function Component() {
...trpc.group.listProfiles.queryOptions({
projectId,
groupId,
cursor: page - 1,
cursor: (page - 1) * 50,
take: 50,
search: debouncedSearch || undefined,
}),

View File

@@ -65,8 +65,8 @@ export class ProfileBuffer extends BaseBuffer {
): Promise<T> {
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');

View File

@@ -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<IServiceGroup[]> {
const conditions = [
`project_id = ${sqlstring.escape(projectId)}`,
'deleted = 0',
...(type ? [`type = ${sqlstring.escape(type)}`] : []),
...(search
? [
@@ -151,6 +153,7 @@ export async function getGroupListCount({
}): Promise<number> {
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<string[]> {
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()}%`)})`
: '';

View File

@@ -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')