perf(api): improve inserting events

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-12 22:09:35 +02:00
parent 46fe17e558
commit efd24ca67a
4 changed files with 133 additions and 19 deletions

View File

@@ -622,7 +622,7 @@ export async function getTopPages({
}) {
const res = await chQuery<IServicePage>(`
SELECT path, count(*) as count, project_id, first_value(created_at) as first_seen, max(properties['__title']) as title, origin
FROM events_v2
FROM ${TABLE_NAMES.events}
WHERE name = 'screen_view'
AND project_id = ${escape(projectId)}
AND created_at > now() - INTERVAL 30 DAY

View File

@@ -49,7 +49,7 @@ export async function getProfileById(id: string, projectId: string) {
}
const [profile] = await chQuery<IClickhouseProfile>(
`SELECT * FROM profiles WHERE id = ${escape(String(id))} AND project_id = ${escape(projectId)} ORDER BY created_at DESC LIMIT 1`
`SELECT * FROM ${TABLE_NAMES.profiles} WHERE id = ${escape(String(id))} AND project_id = ${escape(projectId)} ORDER BY created_at DESC LIMIT 1`
);
if (!profile) {