Updated date range handling.
This commit is contained in:
@@ -12,6 +12,7 @@ export async function getActiveVisitors(...args: [websiteId: string]) {
|
||||
|
||||
async function relationalQuery(websiteId: string) {
|
||||
const { rawQuery } = prisma;
|
||||
const startDate = subMinutes(new Date(), 5);
|
||||
|
||||
const result = await rawQuery(
|
||||
`
|
||||
@@ -20,7 +21,7 @@ async function relationalQuery(websiteId: string) {
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at >= {{startDate}}
|
||||
`,
|
||||
{ websiteId, startDate: subMinutes(new Date(), 5) },
|
||||
{ websiteId, startDate },
|
||||
);
|
||||
|
||||
return result[0] ?? null;
|
||||
@@ -28,6 +29,7 @@ async function relationalQuery(websiteId: string) {
|
||||
|
||||
async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {
|
||||
const { rawQuery } = clickhouse;
|
||||
const startDate = subMinutes(new Date(), 5);
|
||||
|
||||
const result = await rawQuery(
|
||||
`
|
||||
@@ -37,7 +39,7 @@ async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startDate:DateTime64}
|
||||
`,
|
||||
{ websiteId, startDate: subMinutes(new Date(), 5) },
|
||||
{ websiteId, startDate },
|
||||
);
|
||||
|
||||
return result[0] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user