Updated pixel/link endpoints. Added name to rawQuery.

This commit is contained in:
Mike Cao 2025-09-30 16:11:21 -07:00
parent b9fbbc6453
commit 8a977b0164
18 changed files with 913 additions and 810 deletions

View file

@ -3,6 +3,8 @@ import prisma from '@/lib/prisma';
import clickhouse from '@/lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from '@/lib/db';
const FUNCTION_NAME = 'getActiveVisitors';
export async function getActiveVisitors(...args: [websiteId: string]) {
return runQuery({
[PRISMA]: () => relationalQuery(...args),
@ -22,6 +24,7 @@ async function relationalQuery(websiteId: string) {
and created_at >= {{startDate}}
`,
{ websiteId, startDate },
FUNCTION_NAME,
);
return result?.[0] ?? null;
@ -40,6 +43,7 @@ async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {
and created_at >= {startDate:DateTime64}
`,
{ websiteId, startDate },
FUNCTION_NAME,
);
return result[0] ?? null;