fix parseFilters

This commit is contained in:
Brian Cao 2022-07-22 19:50:43 -07:00
parent aa8057f9fe
commit 1c26581cd1
4 changed files with 17 additions and 11 deletions

View File

@ -1,15 +1,14 @@
import { getDatabase, parseFilters, rawQuery } from 'lib/db';
import { MYSQL, POSTGRESQL } from 'lib/constants';
import { getDatabase, parseFilters, rawQuery, runAnalyticsQuery } from 'lib/db';
import { MYSQL, POSTGRESQL, CLICKHOUSE, RELATIONAL } from 'lib/constants';
export function getPageviewParams(
param,
website_id,
start_at,
end_at,
column,
table,
filters = {},
) {
export async function getPageviewParams(...args) {
return runAnalyticsQuery({
[`${RELATIONAL}`]: () => relationalQuery(...args),
[`${CLICKHOUSE}`]: () => clickhouseQuery(...args),
});
}
function relationalQuery(param, website_id, start_at, end_at, column, table, filters = {}) {
const params = [param, website_id, start_at, end_at];
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
table,
@ -43,3 +42,7 @@ export function getPageviewParams(
params,
);
}
function clickhouseQuery() {
return Promise.reject(new Error('Not implemented.'));
}

View File

@ -64,6 +64,7 @@ async function clickhouseQuery(
const params = [website_id];
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
'pageview',
null,
filters,
params,
sessionKey,

View File

@ -47,6 +47,7 @@ async function clickhouseQuery(website_id, start_at, end_at, field, filters = {}
const params = [website_id];
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
'pageview',
null,
filters,
params,
'session_uuid',

View File

@ -59,6 +59,7 @@ async function clickhouseQuery(website_id, start_at, end_at, filters = {}) {
const params = [website_id];
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
'pageview',
null,
filters,
params,
'session_uuid',