summary filter

This commit is contained in:
2025-04-01 23:00:35 +08:00
parent b187bdefdf
commit 9fa61ccf8d
4 changed files with 32 additions and 5 deletions

View File

@@ -57,6 +57,9 @@ export async function getEventsSummary(params: {
startTime?: string;
endTime?: string;
linkId?: string;
teamIds?: string[];
projectIds?: string[];
tagIds?: string[];
}): Promise<EventsSummary> {
const filter = buildFilter(params);

View File

@@ -56,16 +56,29 @@ export function buildFilter(params: Partial<EventsQueryParams>): string {
filters.push(`user_id = '${params.userId}'`);
}
// 团队ID过滤
if (params.teamId) {
// 团队ID过滤 - 支持多选
if (params.teamIds && params.teamIds.length > 0) {
const teamValues = params.teamIds.map(id => `'${id}'`).join(', ');
filters.push(`team_id IN (${teamValues})`);
} else if (params.teamId) {
filters.push(`team_id = '${params.teamId}'`);
}
// 项目ID过滤
if (params.projectId) {
// 项目ID过滤 - 支持多选
if (params.projectIds && params.projectIds.length > 0) {
const projectValues = params.projectIds.map(id => `'${id}'`).join(', ');
filters.push(`project_id IN (${projectValues})`);
} else if (params.projectId) {
filters.push(`project_id = '${params.projectId}'`);
}
// 标签ID过滤 - 支持多选
if (params.tagIds && params.tagIds.length > 0) {
// 假设我们在link_tags字段存储标签ID的JSON数组
const tagConditions = params.tagIds.map(id => `arrayExists(x -> x = '${id}', JSONExtractArrayRaw(link_tags))`);
filters.push(`(${tagConditions.join(' OR ')})`);
}
return filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : '';
}

View File

@@ -45,7 +45,10 @@ export interface EventsQueryParams {
linkSlug?: string;
userId?: string;
teamId?: string;
teamIds?: string[]; // 团队ID数组支持多选
projectId?: string;
projectIds?: string[]; // 项目ID数组支持多选
tagIds?: string[]; // 标签ID数组支持多选
page?: number;
pageSize?: number;
sortBy?: string;