Fixes clickhouse connection to run metrics

This commit is contained in:
manuelurenah
2024-10-31 11:41:05 -04:00
parent 599c2db9e1
commit 2c563b95f0
6 changed files with 12 additions and 5 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ NEXT_PUBLIC_ADS=true
# Clickhouse
CLICKHOUSE_HOST=http://localhost:18123
CLICKHOUSE_USERNAME=default
CLICKHOUSE_PASSWORD=clickhouse
CLICKHOUSE_PASSWORD=
CLICKHOUSE_TRACKER_URL=http://localhost:3000
# Email
+6
View File
@@ -17,6 +17,12 @@ down:
.PHONY: restart
restart: down start
# Rebuilds the containers
.PHONY: rebuild
rebuild:
docker-compose down \
&& docker-compose up --build -d
# Stop and remove all containers, networks, images, and volumes
.PHONY: burn
burn:
+2 -1
View File
@@ -89,7 +89,8 @@ services:
restart: unless-stopped
clickhouse:
image: clickhouse/clickhouse-server:22.2
image: clickhouse/clickhouse-server
container_name: clickhouse
ports:
- "18123:8123"
- "19000:9000"
+1 -1
View File
@@ -8,7 +8,7 @@ import { env as clientEnv, formatErrors } from './client.mjs';
import { serverSchema } from './schema.mjs';
if (process.env.NODE_ENV === 'development') {
dotenv.config({ path: __dirname + '/../../.env.development' });
dotenv.config({ path: ['.env.local', '.env.development'] });
}
const _serverEnv = serverSchema.safeParse(process.env);
+1 -1
View File
@@ -69,7 +69,7 @@ function getClickHouse() {
}
export let clickhouse: CustomClickHouseClient | undefined;
const shouldConnect = env.CLICKHOUSE_HOST && env.CLICKHOUSE_USERNAME && env.CLICKHOUSE_PASSWORD;
const shouldConnect = env.CLICKHOUSE_HOST && env.CLICKHOUSE_USERNAME;
if (shouldConnect) {
if (isProd) clickhouse = getClickHouse();
else {
+1 -1
View File
@@ -204,7 +204,7 @@ async function getEngagementTasks(ctx: MetricProcessorRunContext) {
tf.timeframe,
${snippets.timeframeSum('ae."createdAt"')} "hideCount"
FROM "ArticleEngagement" ae
JOIN "Article" a ON a.id = bt."entityId" -- ensure the article exists
JOIN "Article" a ON a.id = ae."articleId" -- ensure the article exists
CROSS JOIN (SELECT unnest(enum_range(NULL::"MetricTimeframe")) AS timeframe) tf
WHERE "articleId" IN (${ids}) AND ae.type = 'Hide'
GROUP BY "articleId", tf.timeframe