Made filters work for all reports.

This commit is contained in:
Mike Cao
2025-06-29 23:57:11 -07:00
parent ea83afbc13
commit 8b64029409
46 changed files with 328 additions and 275 deletions

View File

@@ -12,7 +12,9 @@ export async function getWebsiteDateRange(...args: [websiteId: string]) {
async function relationalQuery(websiteId: string) {
const { rawQuery, parseFilters } = prisma;
const { params } = await parseFilters(websiteId, { startDate: new Date(DEFAULT_RESET_DATE) });
const { filterParams } = await parseFilters(websiteId, {
startDate: new Date(DEFAULT_RESET_DATE),
});
const result = await rawQuery(
`
@@ -23,7 +25,7 @@ async function relationalQuery(websiteId: string) {
where website_id = {{websiteId::uuid}}
and created_at >= {{startDate}}
`,
params,
filterParams,
);
return result[0] ?? null;
@@ -31,7 +33,9 @@ async function relationalQuery(websiteId: string) {
async function clickhouseQuery(websiteId: string) {
const { rawQuery, parseFilters } = clickhouse;
const { params } = await parseFilters(websiteId, { startDate: new Date(DEFAULT_RESET_DATE) });
const { filterParams } = await parseFilters(websiteId, {
startDate: new Date(DEFAULT_RESET_DATE),
});
const result = await rawQuery(
`
@@ -42,7 +46,7 @@ async function clickhouseQuery(websiteId: string) {
where website_id = {websiteId:UUID}
and created_at >= {startDate:DateTime64}
`,
params,
filterParams,
);
return result[0] ?? null;