From d3ddc441d5709ab7b3aeda515d2b555e9fc79504 Mon Sep 17 00:00:00 2001 From: Vignesh Shetty Date: Sun, 2 Jun 2024 14:47:51 +0530 Subject: [PATCH] Vercel loc test, commit --- kafka/fixtures/kafka_consumer.sql | 6 ++++-- lib/services/redisPublicGenerate.ts | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/kafka/fixtures/kafka_consumer.sql b/kafka/fixtures/kafka_consumer.sql index 09e13b1..44d7246 100644 --- a/kafka/fixtures/kafka_consumer.sql +++ b/kafka/fixtures/kafka_consumer.sql @@ -60,10 +60,12 @@ CREATE TABLE click_analytics ( `device` LowCardinality(String), `country` LowCardinality(String), `region` String, - `city` String + `city` String, + `timestamp` Date DEFAULT toDate(now()) ) ENGINE = MergeTree() -ORDER BY (code, browser, os, device, country); +PARTITION BY toYYYYMM(timestamp) +ORDER BY (code, timestamp, browser, os, device, country); -- Create a Materialized View named 'click_analytics_consumer' to transfer data from the Kafka table to the ClickHouse table -- The view selects all columns from 'eurl_kafka' and inserts them into the 'click_analytics' table diff --git a/lib/services/redisPublicGenerate.ts b/lib/services/redisPublicGenerate.ts index 0f0bb69..2b1b956 100644 --- a/lib/services/redisPublicGenerate.ts +++ b/lib/services/redisPublicGenerate.ts @@ -48,8 +48,24 @@ const checkIfShortCodePublic = (shortCode: string): boolean => { const publishUserAgent = async (req: NextRequest, code: string) => { const userAgent = userAgentAnlytics(req); - await pubSubRedis.publish( - "user_anlytics", + const tmp_test_data = { +city : req.geo!.city, +country : req.geo!.country, +region : req.geo!.region, +lat : req.geo!.latitude, +long :req.geo!.longitude + } + + await pubSubRedis.lpush( + "user_location", + JSON.stringify({ + code, + ...tmp_test_data, + }) + ); + + await pubSubRedis.lpush( + "user_analytics", JSON.stringify({ code, ...userAgent,