Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update logs + use redis.xadd for now

Steven Tey17773548aeab
diff --git a/apps/web/app/(ee)/api/cron/usage/update-workspace-clicks/route.ts b/apps/web/app/(ee)/api/cron/usage/update-workspace-clicks/route.ts
index 9260b34d2f..f043109c86 100644
--- a/apps/web/app/(ee)/api/cron/usage/update-workspace-clicks/route.ts
+++ b/apps/web/app/(ee)/api/cron/usage/update-workspace-clicks/route.ts
@@ -28,7 +28,9 @@ const aggregateWorkspaceUsage = (
let lastId: string | null = null;
- // The entries are a batch of workspace usage events, each with workspaceId, timestamp, and possibly linkId.
+ console.log(`Aggregating ${entries.length} workspace usage events`);
+
+ // The entries are a batch of workspace usage events, each with workspaceId, timestamp, and linkId.
// We want to aggregate by workspaceId, counting total events (clicks) and tracking first/last timestamps.
for (const entry of entries) {
@@ -84,7 +86,7 @@ const processWorkspaceUpdateStreamBatch = () =>
}
console.log(
- `Processing ${updates.length} aggregated workspace usage updates`,
+ `Processing ${updates.length} aggregated workspace usage updates...`,
);
// Process updates in parallel batches to avoid overwhelming the database
@@ -100,7 +102,6 @@ const processWorkspaceUpdateStreamBatch = () =>
const processedEntryIds: string[] = [];
for (const batch of batches) {
- console.log(`BATCH: ${JSON.stringify(batch)}`);
try {
// Execute all updates in the batch in parallel
const batchPromises = batch.map(async (update) => {
@@ -111,10 +112,6 @@ const processWorkspaceUpdateStreamBatch = () =>
[update.clicks, update.clicks, update.workspaceId],
);
- console.log(
- `Incremented workspace ${update.workspaceId} usage and totalClicks by ${update.clicks}`,
- );
-
processedEntryIds.push(...update.entryIds);
return {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
index 56ffeda82b..237ab705e1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx
@@ -513,7 +513,7 @@ function RowMenuButton({
<Command tabIndex={0} loop className="focus:outline-none">
<Command.List className="w-screen text-sm focus-visible:outline-none sm:w-auto sm:min-w-[200px]">
{row.original.status === "invited" ? (
- <>
+ <Command.Group className="grid gap-px p-1.5">
<MenuItem
icon={Users6}
label="Change group"
@@ -562,7 +562,7 @@ function RowMenuButton({
});
}}
/>
- </>
+ </Command.Group>
) : (
<>
<Command.Group className="grid gap-px p-1.5">
diff --git a/apps/web/lib/upstash/redis-streams.ts b/apps/web/lib/upstash/redis-streams.ts
index 3f5796d990..ebbb85ed13 100644
--- a/apps/web/lib/upstash/redis-streams.ts
+++ b/apps/web/lib/upstash/redis-streams.ts
@@ -157,14 +157,12 @@ export const publishClickEvent = async (event: ClickEvent) => {
const entry = { linkId, timestamp, workspaceId };
try {
- const pipeline = redis.pipeline();
-
// TODO: - Uncomment when we handle click updates
+ // const pipeline = redis.pipeline();
// pipeline.xadd(LINK_CLICK_UPDATES_STREAM_KEY, "*", entry);
-
- pipeline.xadd(WORKSPACE_USAGE_UPDATES_STREAM_KEY, "*", entry);
-
- return await pipeline.exec();
+ // pipeline.xadd(WORKSPACE_USAGE_UPDATES_STREAM_KEY, "*", entry);
+ // return await pipeline.exec();
+ return await redis.xadd(WORKSPACE_USAGE_UPDATES_STREAM_KEY, "*", entry);
} catch (error) {
console.error("Failed to publish click update to streams:", error);
throw error;