| 1186 | import { resolveDateRange } from './date.service'; |
| 1187 | |
| 1188 | export async function getTopEventNames(projectId: string): Promise<string[]> { |
| 1189 | return getCache(`mcp:event-names:${projectId}`, 60 * 10, async () => { |
| 1190 | const rows = await clix(ch) |
| 1191 | .select<IClickhouseEvent>(['name', 'count() as count']) |
| 1192 | .from(TABLE_NAMES.event_names_mv) |
| 1193 | .where('project_id', '=', projectId) |
| 1194 | .groupBy(['name']) |
| 1195 | .orderBy('count', 'DESC') |
| 1196 | .limit(50) |
| 1197 | .execute(); |
| 1198 | |
| 1199 | return rows.map((r) => r.name); |
| 1200 | }); |
| 1201 | } |
| 1202 | |
| 1203 | export const listEventNamesCore = (projectId: string): Promise<string[]> => |
| 1204 | getTopEventNames(projectId); |