From c6d0fde424c9bc0e809d61ea0afbe028f35b957f Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Fri, 29 Sep 2023 11:22:13 -0700 Subject: [PATCH] clean-up protocol, update getDatabaseType logic for CH --- src/components/pages/reports/Report.js | 2 -- src/lib/clickhouse.ts | 7 ++----- src/lib/db.js | 4 ++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/pages/reports/Report.js b/src/components/pages/reports/Report.js index de17aca6..538a444d 100644 --- a/src/components/pages/reports/Report.js +++ b/src/components/pages/reports/Report.js @@ -8,8 +8,6 @@ export const ReportContext = createContext(null); export function Report({ reportId, defaultParameters, children, ...props }) { const report = useReport(reportId, defaultParameters); - //console.log({ report }); - return ( diff --git a/src/lib/clickhouse.ts b/src/lib/clickhouse.ts index c371e7f9..2eed340e 100644 --- a/src/lib/clickhouse.ts +++ b/src/lib/clickhouse.ts @@ -25,16 +25,13 @@ function getClient() { hostname, port, pathname, - // protocol, + protocol, username = 'default', password, } = new URL(process.env.CLICKHOUSE_URL); - // const formattedProtocol = - // protocol.toLowerCase() === 'clickhouse:' || protocol === 'https:' ? 'https:' : 'http:'; - const client = createClient({ - host: `http://${hostname}:${port}`, + host: `${protocol}//${hostname}:${port}`, database: pathname.replace('/', ''), username: username, password, diff --git a/src/lib/db.js b/src/lib/db.js index 750cdec0..6657ad97 100644 --- a/src/lib/db.js +++ b/src/lib/db.js @@ -17,6 +17,10 @@ export function getDatabaseType(url = process.env.DATABASE_URL) { return POSTGRESQL; } + if (process.env.CLICKHOUSE_URL) { + return CLICKHOUSE; + } + return type; }