click subpath

This commit is contained in:
2025-04-10 17:19:40 +08:00
parent ace231b93f
commit 48d5bdafa4
10 changed files with 95 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
import { createClient } from '@clickhouse/client';
import type { EventsQueryParams } from './types';
import { EventsQueryParams } from './analytics';
// ClickHouse 客户端配置
const clickhouse = createClient({
@@ -58,6 +58,13 @@ export function buildFilter(params: Partial<EventsQueryParams>): string {
filters.push(`user_id = '${params.userId}'`);
}
// 添加子路径过滤条件
if (params.subpath) {
console.log('Adding subpath filter:', params.subpath);
// 使用 url 字段和字符串函数替代不存在的 path 字段
filters.push(`positionCaseInsensitive(url, '/${params.subpath}') > 0`);
}
// 添加团队ID过滤条件
if (params.teamId) {
filters.push(`team_id = '${params.teamId}'`);